コード例 #1
0
 /**
  * Unsets the current service as purgeable in zookeeper
  *
  * @param artifact - The artifact being deployed
  */
 private void unsetPurgeable(DeploymentArtifact artifact) {
   ServicePurgeClient client = null;
   String serviceName = getServiceId(artifact);
   String appName = getAppId(artifact);
   try {
     client = new ServicePurgeClient(this.zookeeperConnectionString);
     client.removePurgeService(appName, serviceName);
   } catch (Exception purgeException) {
     log.error(
         "Unable to unset application: {}, service: {} as purgeable Message: {}",
         appName,
         serviceName,
         purgeException.getMessage());
   } finally {
     if (client != null) client.close();
   }
 }
コード例 #2
0
 private void registerSecurityIDWithServiceDiscovery(DeploymentMetadata artifact)
     throws DeploymentException {
   if (serviceDiscovery == null) {
     log.warn(
         "Service Discovery is not set, so can not register security id.  Check zookeeper config");
     return; // if not configured to use, skip this step
   }
   Preconditions.checkState(
       !Strings.isNullOrEmpty(getSecurityId(artifact)),
       "A security ID MUST be passed in for the application/service");
   try {
     if (Strings.isNullOrEmpty(getAppId(artifact))
         || getAppId(artifact).equals("common_services")) {
       log.info(
           "Registering common service "
               + getServiceId(artifact)
               + " secId="
               + getSecurityId(artifact));
       serviceDiscovery.setSecurityIdForCommonService(
           getServiceId(artifact), getSecurityId(artifact));
     } else {
       log.info(
           "Registering "
               + getAppId(artifact)
               + ":"
               + getServiceId(artifact)
               + " secId="
               + getSecurityId(artifact));
       serviceDiscovery.setSecurityIdForApplication(getAppId(artifact), getSecurityId(artifact));
     }
   } catch (Exception e) {
     log.error(
         s(
             "Error while registering with service discovery for [%s:%s]",
             nullToEmpty(getAppId(artifact)), getServiceId(artifact)),
         e);
     throw new DeploymentException(e.getMessage());
   }
 }