Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013-2014 by Cisco Systems, Inc. All rights reserved.
  
  package com.cisco.oss.foundation.directory.impl;
  
  import org.slf4j.Logger;
  
The RegistrationManager implementation.

Author(s):
zuxiang
 
 public class RegistrationManagerImpl implements RegistrationManagerClosable{
 	
 	private static final Logger LOGGER = LoggerFactory
The Registration heartbeat and health check enabled property name.
 
 	public static final String SD_API_HEARTBEAT_ENABLED_PROPERTY = "heartbeat.enabled";

the default value of hearbeat enabled property value.
 
 	public static final boolean SD_API_HEARTBEAT_ENABLED_DEFAULT = true;

The DirectoryServiceClientManager.
 
Mark component started or not
 
 	private boolean isStarted = false;

The DirectoryRegistrationService to do Service Registration.
 
Constructor.
 
 	public RegistrationManagerImpl(DirectoryServiceClientManager directoryServiceClientManager){
 		this. = directoryServiceClientManager;
 	}

Start the RegistrationManagerImpl. it is idempotent, it can be invoked multiple times while in same state and is not thread safe.
 
 	public void start(){
 		if(!){
 			synchronized (this) {
 				if (!) {
 					 = true;
 				}
 			}
 		}
 		
 	}

Stop the RegistrationManagerImpl it is idempotent, it can be invoked in multiple times while in same state. But not thread safe.
 
 	public void stop(){
 		if () {
 			synchronized (this) {
 				if () {
 					if (getRegistrationService() instanceof Closable) {
 					}
 					 = false;
 				}
 			}
		}
	}

	public void registerService(ProvidedServiceInstance serviceInstance)
		if(! ){
			throw new ServiceException(error);
		}
		if(serviceInstance == null){
			throw new IllegalArgumentException("The ServiceInstance argument is null.");
		}
		ErrorCode code = ServiceInstanceUtils.validateProvidedServiceInstance(serviceInstance);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceInstance.getServiceName());
			throw new ServiceException(error);
		}
		try{
			throw new ServiceException(e);
		}
	}

	public void registerService(ProvidedServiceInstance serviceInstance,
			ServiceInstanceHealth registryHealththrows ServiceException {
		if(! ){
			throw new ServiceException(error);
		}
		if(serviceInstance == null){
			throw new IllegalArgumentException("The ServiceInstance argument is null.");
		}
		ErrorCode code = ServiceInstanceUtils.validateProvidedServiceInstance(serviceInstance);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceInstance.getServiceName());
			throw new ServiceException(error);
		}
		try{
			getRegistrationService().registerService(serviceInstanceregistryHealth);
			throw new ServiceException(e);
		}
	}

	public void updateServiceUri(String serviceName,
			String providerIdString urithrows ServiceException {
		if(! ){
			throw new ServiceException(error);
		}
		ErrorCode code = ServiceInstanceUtils.isNameValid(serviceName);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		code = ServiceInstanceUtils.isIdValid(providerId);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		code = ServiceInstanceUtils.isUriValid(uri);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		try{
			getRegistrationService().updateServiceUri(serviceNameproviderIduri);
			throw new ServiceException(e);
		}
	}

	public void updateServiceOperationalStatus(String serviceName,
			String providerIdOperationalStatus statusthrows ServiceException {
		if(! ){
			throw new ServiceException(error);
		}
		ErrorCode code = ServiceInstanceUtils.isNameValid(serviceName);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		code = ServiceInstanceUtils.isIdValid(providerId);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
        try{
			getRegistrationService().updateServiceOperationalStatus(serviceNameproviderIdstatus);
			throw new ServiceException(e);
		}
	}

	public void updateService(ProvidedServiceInstance serviceInstance)
		if(! ){
			throw new ServiceException(error);
		}
		if(serviceInstance == null){
			throw new IllegalArgumentException("The ServiceInstance argument is null.");
		}
		ErrorCode code = ServiceInstanceUtils.validateProvidedServiceInstance(serviceInstance);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceInstance.getServiceName());
			throw new ServiceException(error);
		}
		try{
			throw new ServiceException(e);
		}
	}

	public void unregisterService(String serviceNameString providerId)
		if(! ){
			throw new ServiceException(error);
		}
		ErrorCode code = ServiceInstanceUtils.isNameValid(serviceName);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		code = ServiceInstanceUtils.isIdValid(providerId);
		if(! code.equals(.)){
			ServiceDirectoryError error = new ServiceDirectoryError(codeserviceName);
			throw new ServiceException(error);
		}
		try{
			getRegistrationService().unregisterService(serviceNameproviderId);
			throw new ServiceException(e);
		}
	}
		if( == null){
			synchronized(this){
				if( == null){
					boolean heartbeatEnabled = Configurations.getBoolean(,
					if(heartbeatEnabled){
						service.start();
						.info("Created the HeartbeatDirectoryRegistrationService in RegistrationManager");
else {
						.info("Created the DirectoryRegistrationService in RegistrationManager");
					}
				}
			}
		}
	}
New to GrepCode? Check out our FAQ X