List of usage examples for org.apache.hadoop.registry.client.types ServiceRecord ServiceRecord
public ServiceRecord()
From source file:org.apache.hive.service.server.HS2ActivePassiveHARegistry.java
License:Apache License
private ServiceRecord getNewServiceRecord() { ServiceRecord srv = new ServiceRecord(); final Map<String, String> confsToPublish = getConfsToPublish(); for (Map.Entry<String, String> entry : confsToPublish.entrySet()) { srv.set(entry.getKey(), entry.getValue()); }//w ww . j a va2 s . c o m return srv; }
From source file:org.apache.slider.providers.agent.TestAgentProviderService.java
License:Apache License
protected YarnRegistryViewForProviders createYarnRegistryViewForProviders(Configuration conf) throws IOException { conf.set(SliderXmlConfKeys.REGISTRY_PATH, SliderXmlConfKeys.DEFAULT_REGISTRY_PATH); RegistryOperations registryOperations = new MockRegistryOperations(); registryOperations.init(conf);//from www . jav a 2s . c o m YarnRegistryViewForProviders registryViewForProviders = new YarnRegistryViewForProviders(registryOperations, "hbase", SliderKeys.APP_TYPE, "hbase1", new MockApplicationAttemptId(new MockApplicationId(1), 1)); registryViewForProviders.registerSelf(new ServiceRecord(), true); return registryViewForProviders; }
From source file:org.apache.slider.providers.hbase.HBaseProviderService.java
License:Apache License
private void registerHBaseServiceEntry() throws IOException { String name = amState.getApplicationName(); ServiceRecord serviceRecord = new ServiceRecord(); // bond lifespan to the application serviceRecord.set(YarnRegistryAttributes.YARN_ID, yarnRegistry.getApplicationAttemptId().getApplicationId().toString()); serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION); try {//from ww w.j av a 2s . c om URL configURL = new URL(amWebAPI, SLIDER_PATH_PUBLISHER + "/" + HBASE_SERVICE_TYPE); serviceRecord.addExternalEndpoint(RegistryTypeUtils .restEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, configURL.toURI())); } catch (URISyntaxException e) { log.warn("failed to create config URL: {}", e, e); } log.info("registering {}/{}", name, HBASE_SERVICE_TYPE); yarnRegistry.putService(HBASE_SERVICE_TYPE, name, serviceRecord, true); PublishedConfiguration publishedSite = new PublishedConfiguration("HBase site", siteConf); PublishedConfigSet configSet = amState.getOrCreatePublishedConfigSet(HBASE_SERVICE_TYPE); configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite); }
From source file:org.apache.slider.server.appmaster.SliderAppMaster.java
License:Apache License
/** * This registers the service instance and its external values * @param instanceName name of this instance * @param appid application ID/*w ww.j a va2 s .c om*/ * @throws IOException */ private void registerServiceInstance(String instanceName, ApplicationId appid) throws IOException { // the registry is running, so register services URL amWebURI = new URL(appMasterTrackingUrl); URL agentOpsURI = new URL(agentOpsUrl); URL agentStatusURI = new URL(agentStatusUrl); //Give the provider restricted access to the state, registry setupInitialRegistryPaths(); yarnRegistryOperations = new YarnRegistryViewForProviders(registryOperations, service_user_name, SliderKeys.APP_TYPE, instanceName, appAttemptID); providerService.bindToYarnRegistry(yarnRegistryOperations); sliderAMProvider.bindToYarnRegistry(yarnRegistryOperations); // Yarn registry ServiceRecord serviceRecord = new ServiceRecord(); serviceRecord.set(YarnRegistryAttributes.YARN_ID, appid.toString()); serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION); serviceRecord.description = "Slider Application Master"; /* SLIDER-531: disable this addition so things compile against versions of the registry with/without the new record format serviceRecord.addExternalEndpoint( RegistryTypeUtils.ipcEndpoint( CustomRegistryConstants.AM_IPC_PROTOCOL, rpcServiceAddress)); */ // internal services sliderAMProvider.applyInitialRegistryDefinitions(amWebURI, agentOpsURI, agentStatusURI, serviceRecord); // provider service dynamic definitions. providerService.applyInitialRegistryDefinitions(amWebURI, agentOpsURI, agentStatusURI, serviceRecord); // register the service's entry log.info("Service Record \n{}", serviceRecord); yarnRegistryOperations.registerSelf(serviceRecord, true); log.info("Registered service under {}; absolute path {}", yarnRegistryOperations.getSelfRegistrationPath(), yarnRegistryOperations.getAbsoluteSelfRegistrationPath()); boolean isFirstAttempt = 1 == appAttemptID.getAttemptId(); // delete the children in case there are any and this is an AM startup. // just to make sure everything underneath is purged if (isFirstAttempt) { yarnRegistryOperations.deleteChildren(yarnRegistryOperations.getSelfRegistrationPath(), true); } }
From source file:org.apache.slider.server.appmaster.SliderAppMaster.java
License:Apache License
/** * Handler for {@link RegisterComponentInstance action} * Register/re-register an ephemeral container that is already in the app state * @param id the component// w w w. j a v a2s .c om * @param description */ public boolean registerComponent(ContainerId id, String description) throws IOException { RoleInstance instance = appState.getOwnedContainer(id); if (instance == null) { return false; } // this is where component registrations go log.info("Registering component {}", id); String cid = RegistryPathUtils.encodeYarnID(id.toString()); ServiceRecord container = new ServiceRecord(); container.set(YarnRegistryAttributes.YARN_ID, cid); container.description = description; container.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.CONTAINER); try { yarnRegistryOperations.putComponent(cid, container); } catch (IOException e) { log.warn("Failed to register container {}/{}: {}", id, description, e, e); } return true; }
From source file:org.apache.slider.server.appmaster.TestServiceRecordAttributes.java
License:Apache License
@Test public void testAppConfigProvidedServiceRecordAttributes() throws Exception { Map<String, String> options = new HashMap<>(); options.put("slider.some.arbitrary.option", "arbitrary value"); options.put("service.record.attribute.one_attribute", "one_attribute_value"); options.put("service.record.attribute.second_attribute", "second_attribute_value"); MapOperations serviceProps = new MapOperations(SliderKeys.COMPONENT_AM, options); options = new HashMap<>(); options.put("some.component.attribute", "component_attribute_value"); options.put("service.record.attribute.component_attribute", "component_attribute_value"); MapOperations compProps = new MapOperations("TEST_COMP", options); SliderAppMaster appMaster = new SliderAppMaster(); ServiceRecord appServiceRecord = new ServiceRecord(); appMaster.setProvidedServiceRecordAttributes(serviceProps, appServiceRecord); assertNull("property should not be attribute", appServiceRecord.get("slider.some.arbitrary.option")); assertEquals("wrong value", "one_attribute_value", appServiceRecord.get("one_attribute")); assertEquals("wrong value", "second_attribute_value", appServiceRecord.get("second_attribute")); ServiceRecord compServiceRecord = new ServiceRecord(); appMaster.setProvidedServiceRecordAttributes(compProps, compServiceRecord); assertNull("should not be attribute", compServiceRecord.get("some.component.attribute")); assertEquals("wrong value", "component_attribute_value", compServiceRecord.get("component_attribute")); }