Search in sources :

Example 1 with StaticMicroserviceVersions

use of org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions in project java-chassis by ServiceComb.

the class InstanceCacheChecker method check.

public InstanceCacheSummary check() {
    instanceCacheSummary.setAppId(RegistryUtils.getMicroservice().getAppId());
    instanceCacheSummary.setMicroserviceName(RegistryUtils.getMicroservice().getServiceName());
    instanceCacheSummary.setTimestamp(clock.millis());
    for (MicroserviceManager microserviceManager : appManager.getApps().values()) {
        for (MicroserviceVersions microserviceVersions : microserviceManager.getVersionsByName().values()) {
            if (microserviceVersions instanceof StaticMicroserviceVersions) {
                continue;
            }
            InstanceCacheResult instanceCacheResult = check(microserviceVersions);
            addInstanceCacheResult(instanceCacheResult);
        }
    }
    generateStatus();
    return instanceCacheSummary;
}
Also used : MicroserviceManager(org.apache.servicecomb.registry.consumer.MicroserviceManager) StaticMicroserviceVersions(org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions) MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) StaticMicroserviceVersions(org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions)

Example 2 with StaticMicroserviceVersions

use of org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions in project java-chassis by ServiceComb.

the class MicroserviceReferenceConfig method mark3rdPartyService.

private void mark3rdPartyService(OperationMeta operationMeta, ReferenceConfig referenceConfig) {
    final MicroserviceVersions microserviceVersions = DiscoveryManager.INSTANCE.getOrCreateMicroserviceVersions(operationMeta.getMicroserviceMeta().getAppId(), operationMeta.getMicroserviceName());
    referenceConfig.setThirdPartyService(microserviceVersions instanceof StaticMicroserviceVersions);
}
Also used : MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) StaticMicroserviceVersions(org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions) StaticMicroserviceVersions(org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions)

Example 3 with StaticMicroserviceVersions

use of org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions in project java-chassis by ServiceComb.

the class RegistrationManager method registerMicroserviceMapping.

/**
 * <p>
 * Register a third party service if not registered before, and set it's instances into
 * {@linkplain StaticMicroserviceVersions StaticMicroserviceVersions}.
 * </p>
 * <p>
 * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has,
 * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}.
 * </p>
 * <em>
 *   This method is for initializing 3rd party service endpoint config.
 *   i.e. If this service has not been registered before, this service will be registered and the instances will be set;
 *   otherwise, NOTHING will happen.
 * </em>
 *
 * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId
 * @param version version of this 3rd party service
 * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other
 * necessary information will be generate and set in the implementation of this method.
 * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and
 * can also be used for the proxy interface of RPC style invocation.
 */
public void registerMicroserviceMapping(String microserviceName, String version, List<MicroserviceInstance> instances, Class<?> schemaIntfCls) {
    MicroserviceNameParser parser = new MicroserviceNameParser(getAppId(), microserviceName);
    MicroserviceManager microserviceManager = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceManager(parser.getAppId());
    microserviceManager.getVersionsByName().computeIfAbsent(microserviceName, svcName -> new StaticMicroserviceVersions(DiscoveryManager.INSTANCE.getAppManager(), parser.getAppId(), microserviceName).init(schemaIntfCls, version, instances));
}
Also used : MicroserviceManager(org.apache.servicecomb.registry.consumer.MicroserviceManager) StaticMicroserviceVersions(org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions) MicroserviceNameParser(org.apache.servicecomb.registry.definition.MicroserviceNameParser)

Aggregations

StaticMicroserviceVersions (org.apache.servicecomb.registry.consumer.StaticMicroserviceVersions)3 MicroserviceManager (org.apache.servicecomb.registry.consumer.MicroserviceManager)2 MicroserviceVersions (org.apache.servicecomb.registry.consumer.MicroserviceVersions)2 MicroserviceNameParser (org.apache.servicecomb.registry.definition.MicroserviceNameParser)1