Edit the Cached ProvidedServiceInstance when updateService is called.

It is thread safe.

@param instance
the ProvidedServiceInstance.
965687
private void editCachedServiceInstance(ProvidedServiceInstance instance) {
        try {
            write.lock();
            ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
                    instance.getProviderId());
            CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);
            if(cachedInstance != null){
                cachedInstance.setMonitorEnabled(instance.isMonitorEnabled());
                cachedInstance.setStatus(instance.getStatus());
            }
            
            LOGGER.debug("update cached ProvidedServiceInstance: {}.", cachedInstance.toString());

        } finally {
            write.unlock();
        }
    }
651208
public void
setCache(Cache cache) {
	if (cache == null) {
		this.cache = new Cache(dclass);
		this.temporary_cache = true;
	} else {
		this.cache = cache;
		this.temporary_cache = false;
	}
}
498174
@Override
    public void registerService(ServiceInstance<T> service) throws Exception
    {
        Entry<T> newEntry = new Entry<T>(service);
        Entry<T> oldEntry = services.putIfAbsent(service.getId(), newEntry);
        Entry<T> useEntry = (oldEntry != null) ? oldEntry : newEntry;
        synchronized(useEntry)
        {
            if ( useEntry == newEntry ) // i.e. is new
            {
                useEntry.cache = makeNodeCache(service);
            }
            internalRegisterService(service);
        }
    }
1123495
public void updateInstance(
      Instance my_instance,
      final String my_client_project,
      final String my_instance_id,
      final String my_display_name) {
    // [START instance_admin_client_update_instance]
    Instance instance = my_instance;
    final String clientProject = my_client_project;
    final String instanceId = my_instance_id;

    final String newDisplayName = my_display_name;

    InstanceInfo toUpdate =
        InstanceInfo.newBuilder(InstanceId.of(clientProject, instanceId))
            .setDisplayName(newDisplayName)
            .setNodeCount(instance.getNodeCount() + 1)
            .build();
    // Only update display name
    OperationFuture<Instance, UpdateInstanceMetadata> op =
        instanceAdminClient.updateInstance(toUpdate, InstanceInfo.InstanceField.DISPLAY_NAME);
    try {
      op.get();
    } catch (ExecutionException e) {
      throw (SpannerException) e.getCause();
    } catch (InterruptedException e) {
      throw SpannerExceptionFactory.propagateInterrupt(e);
    }
    // [END instance_admin_client_update_instance]
  }
175758
public void updateServiceInstanceStatus(String serviceName, String instanceId, OperationalStatus status, final RegistrationCallback cb, Object context){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.UpdateServiceInstanceStatus);

        UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol(serviceName, instanceId, status);

        ProtocolCallback pcb = new ProtocolCallback(){

            @Override
            public void call(boolean result, Response response,
                    ErrorCode error, Object ctx) {
                cb.call(result, error, ctx);
            }

        };

        connection.submitCallbackRequest(header, p, pcb, context);
    }
936862
public void addInstance(InstanceInfo i) {
        instancesMap.put(i.getId(), i);
        synchronized (instances) {
            instances.remove(i);
            instances.add(i);
            isDirty = true;
        }
    }
576347
private void start(final ResourceInstanceEntity instance)
	{
		azure.start(instance.getProviderInstanceId());

		instance.setState(ResourceInstanceState.PROVISIONING);
	}
962905
public void addInstance(Object instance)
            throws Exception
    {
        if (isDestroyed()) {
            throw new IllegalStateException("System already stopped");
        }
        else {
            startInstance(instance);
            if (methodsMap.get(instance.getClass()).hasFor(PreDestroy.class)) {
                managedInstances.add(instance);
            }
        }
    }
157574
protected void onServiceInstanceChanged(ServiceInstance instance){
        String serviceName = instance.getServiceName();
        synchronized(notificationHandlers){
            if(notificationHandlers.containsKey(serviceName)){
                for(NotificationHandler h : notificationHandlers.get(serviceName)){
                    h.serviceInstanceChange(instance);
                }
            }
        }
    }
67165
private void printServiceInstance(ServiceInstance instance) {
        print("\nServiceInstance\n-------------------------");
        if (instance == null) {
            print("null");
            return;
        }
        print("serviceName:  " + instance.getServiceName());
        print("status:  " + instance.getStatus());
        print("uri:  " + instance.getUri());
        print("address:  " + instance.getAddress());
        print("monitorEnabled:  " + instance.isMonitorEnabled());
        print("metadata:");
        Map<String, String> meta = instance.getMetadata();
        for (Entry<String, String> entry : meta.entrySet()) {
            print("  " + entry.getKey() + "  =>  " + entry.getValue());
        }
    }
998974
@Override
    public void deleteInstance(String instanceId) {
        modifyInstance(instanceId, map -> {
            Instance deletedInstance = map.remove(instanceId);
            getDeletedInstancesByIdMap().put(deletedInstance.getId(), deletedInstance);
        });
    }
483469
public void registerService(ProvidedServiceInstance serviceInstance, ServiceInstanceHealth registryHealth) {
        // Monitor disabled ProvidedServiceInstance should not have the ServiceInstanceHealth.
        if(serviceInstance.isMonitorEnabled()== false){
            throw new ServiceException(ErrorCode.SERVICE_INSTANCE_HEALTH_ERROR);
        }
        registerService(serviceInstance);
    }
53960
public void registerInstance(ProvidedServiceInstance instance){
        String body = _serialize(instance);
        HttpResponse result = invoker.invoke(toInstanceUri(instance.getServiceName(), instance.getProviderId()), body,
                HttpMethod.POST);

        if (result.getHttpCode() != HTTP_CREATED) {
            throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR,
                    "HTTP Code is not OK, code=%s",result.getHttpCode());
        }
    }
260379
public void cache(String key, Object obj) {
        H.Session sess = session();
        if (null != sess) {
            sess.cache(key, obj);
        } else {
            app().cache().put(key, obj);
        }
    }
1127468
@Override
    public void setService(final String name, final FrameworkSupportService service){
        synchronized (services){
            if(null==services.get(name) && null!=service) {
                services.put(name, service);
            }else if(null==service) {
                services.remove(name);
            }
        }
    }
225944
public void putService(K serviceName, V service){
        if(cache.containsKey(serviceName)){
            cache.remove(serviceName);
        }
        cache.put(serviceName, service);
    }
871358
def on_service_modify(self, svc_ref, old_properties):
        
        with self._lock:
            if self.reference is None:
                # A previously registered service now matches our filter
                self.on_service_arrival(svc_ref)
            elif svc_ref is self.reference:
                # Notify the property modification
                self._ipopo_instance.update(
                    self, self._value, svc_ref, old_properties
                )