public String getHostPath() { String hostPath = RegistryUtils.servicePath( JstormKeys.APP_TYPE, this.instanceName, host); return hostPath; }
public String getSupervisorSlotPorts(int memory, int vcores, String supervisorHost) throws Exception { String hostPath = RegistryUtils.servicePath( JOYConstants.APP_TYPE, this.instanceName, supervisorHost); tryHostLock(hostPath); try { List<String> relist; int slotCount = getSlotCount(memory, vcores); LOG.info("slotCount:" + slotCount); relist = getSetPortUsedBySupervisor(supervisorHost, slotCount); LOG.info("get ports string:" + JstormYarnUtils.join(relist, JOYConstants.COMMA, false)); return JstormYarnUtils.join(relist, JOYConstants.COMMA, false); } catch (Exception e) { LOG.error(e); throw e; } finally { releaseHostLock(hostPath); } }
try { Thread.sleep(JOYConstants.HEARTBEAT_TIME_INTERVAL); appPath = RegistryUtils.servicePath( JOYConstants.APP_TYPE, jstormMasterContext.instanceName, jstormMasterContext.appAttemptID.getApplicationId().toString()); ServiceRecord app = new ServiceRecord(); appPath = RegistryUtils.servicePath( JOYConstants.APP_TYPE, jstormMasterContext.instanceName, jstormMasterContext.appAttemptID.getApplicationId().toString()); try {
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
String path = RegistryUtils.servicePath( JOYConstants.APP_NAME, JOYConstants.APP_TYPE, instanceName); String hostPath = RegistryUtils.componentPath( List<String> instanceNames = registryOperations.list(appPath); for (String instance : instanceNames) { String servicePath = RegistryUtils.servicePath( JOYConstants.APP_NAME, JOYConstants.APP_TYPE, instance); Map<String, ServiceRecord> hosts = RegistryUtils.listServiceRecords(registryOperations, servicePath);
String subAppPath = RegistryUtils.servicePath( JOYConstants.APP_TYPE, instance, subapp); String componentsPath = subAppPath + JOYConstants.COMPONENTS;
String appPath = RegistryUtils.servicePath( JOYConstants.APP_TYPE, jstormMasterContext.instanceName, jstormMasterContext.appAttemptID.getApplicationId().toString()); String instancePath = RegistryUtils.serviceclassPath(
/** * Get the registry path for an instance under the user's home node * @param instanceName application instance * @return a path to the registry location for this application instance. */ public static String registryPathForInstance(String instanceName) { return RegistryUtils.servicePath( RegistryUtils.currentUser(), SliderKeys.APP_TYPE, instanceName ); }
/** * Get the registry path for an instance under the user's home node * @param instanceName application instance * @return a path to the registry location for this application instance. */ public static String registryPathForInstance(String instanceName) { return RegistryUtils.servicePath( RegistryUtils.currentUser(), SliderKeys.APP_TYPE, instanceName ); }
/** * Create a path for listing components under a service * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String componentListPath(String user, String serviceClass, String serviceName) { return join(servicePath(user, serviceClass, serviceName), RegistryConstants.SUBPATH_COMPONENTS); }
/** * Create a path for listing components under a service * @param user username or "" * @param serviceClass service name * @param serviceName service name unique for that user and service class * @return a full path */ public static String componentListPath(String user, String serviceClass, String serviceName) { return join(servicePath(user, serviceClass, serviceName), RegistryConstants.SUBPATH_COMPONENTS); }
public static ServiceRecord lookupServiceRecord(RegistryOperations rops, String user, String type, String name) throws IOException, SliderException { if (StringUtils.isEmpty(user)) { user = currentUser(); } else { user = RegistryPathUtils.encodeForRegistry(user); } if (StringUtils.isEmpty(type)) { type = SliderKeys.APP_TYPE; } String path = servicePath(user, type, name); return resolve(rops, path); }
public static ServiceRecord lookupServiceRecord(RegistryOperations rops, String user, String type, String name) throws IOException, SliderException { if (StringUtils.isEmpty(user)) { user = currentUser(); } else { user = RegistryPathUtils.encodeForRegistry(user); } if (StringUtils.isEmpty(type)) { type = SliderKeys.APP_TYPE; } String path = servicePath(user, type, name); return resolve(rops, path); }
/** * Look up an external REST API * @param user user which will be qualified as per {@link #qualifyUser(String)} * @param serviceClass service class * @param instance instance name * @param api API * @return the API, or an exception is raised. * @throws IOException */ public String lookupExternalRestAPI(String user, String serviceClass, String instance, String api) throws IOException { String qualified = qualifyUser(user); String path = servicePath(qualified, serviceClass, instance); String restAPI = resolveExternalRestAPI(api, path); if (restAPI == null) { throw new PathNotFoundException(path + " API " + api); } return restAPI; }
/** * Look up an external REST API * @param user user which will be qualified as per {@link #qualifyUser(String)} * @param serviceClass service class * @param instance instance name * @param api API * @return the API, or an exception is raised. * @throws IOException */ public String lookupExternalRestAPI(String user, String serviceClass, String instance, String api) throws IOException { String qualified = qualifyUser(user); String path = servicePath(qualified, serviceClass, instance); String restAPI = resolveExternalRestAPI(api, path); if (restAPI == null) { throw new PathNotFoundException(path + " API " + api); } return restAPI; }
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
@Test public void testComplexUsernames() throws Throwable { operations.mknode("/users/user with spaces", true); operations.mknode("/users/user-with_underscores", true); operations.mknode("/users/000000", true); operations.mknode("/users/-storm", true); operations.mknode("/users/windows\\ user", true); String home = RegistryUtils.homePathForUser("\u0413PA\u0414_3"); operations.mknode(home, true); operations.mknode( RegistryUtils.servicePath(home, "service.class", "service 4_5"), true); operations.mknode( RegistryUtils.homePathForUser("hbase@HADOOP.APACHE.ORG"), true); operations.mknode( RegistryUtils.homePathForUser("hbase/localhost@HADOOP.APACHE.ORG"), true); home = RegistryUtils.homePathForUser("ADMINISTRATOR/127.0.0.1"); assertTrue("No 'administrator' in " + home, home.contains("administrator")); operations.mknode( home, true); } }
@Test public void testComplexUsernames() throws Throwable { operations.mknode("/users/user with spaces", true); operations.mknode("/users/user-with_underscores", true); operations.mknode("/users/000000", true); operations.mknode("/users/-storm", true); operations.mknode("/users/windows\\ user", true); String home = RegistryUtils.homePathForUser("\u0413PA\u0414_3"); operations.mknode(home, true); operations.mknode( RegistryUtils.servicePath(home, "service.class", "service 4_5"), true); operations.mknode( RegistryUtils.homePathForUser("hbase@HADOOP.APACHE.ORG"), true); operations.mknode( RegistryUtils.homePathForUser("hbase/localhost@HADOOP.APACHE.ORG"), true); home = RegistryUtils.homePathForUser("ADMINISTRATOR/127.0.0.1"); assertTrue("No 'administrator' in " + home, home.contains("administrator")); operations.mknode( home, true); } }
client.actionCreate(exampleApp); waitForServiceToBeStable(client, exampleApp); String serviceZKPath = RegistryUtils.servicePath(RegistryUtils .currentUser(), YarnServiceConstants.APP_TYPE, exampleApp.getName()); Assert.assertTrue("Registry ZK service path doesn't exist",