List of usage examples for org.apache.hadoop.registry.client.types ServiceRecord get
public String get(String key)
From source file:org.apache.hive.service.server.HiveServer2Instance.java
License:Apache License
public HiveServer2Instance(final ServiceRecord srv, final String endPointName) throws IOException { super(srv, endPointName); Endpoint activeEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.ACTIVE_ENDPOINT); Endpoint passiveEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.PASSIVE_ENDPOINT); this.isLeader = activeEndpoint != null; Preconditions.checkArgument(activeEndpoint == null || passiveEndpoint == null, "Incorrect service record. Both active and passive endpoints cannot be non-null!"); this.transportMode = srv.get(HiveConf.ConfVars.HIVE_SERVER2_TRANSPORT_MODE.varname); if (transportMode.equalsIgnoreCase("http")) { this.httpEndpoint = srv.get(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_PATH.varname); } else {// www . j av a 2 s .c om this.httpEndpoint = ""; } }
From source file:org.apache.hive.service.server.HS2ActivePassiveHARegistry.java
License:Apache License
private void updateEndpoint(final ServiceRecord srv, final String endpointName) { final String instanceUri = srv.get(INSTANCE_URI_CONFIG); final String[] tokens = instanceUri.split(":"); final String hostname = tokens[0]; final int port = Integer.parseInt(tokens[1]); Endpoint urlEndpoint = RegistryTypeUtils.ipcEndpoint(endpointName, new InetSocketAddress(hostname, port)); srv.addInternalEndpoint(urlEndpoint); LOG.info("Added {} endpoint to service record", urlEndpoint); }
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")); }