use of org.apache.twill.discovery.Discoverable in project cdap by caskdata.
the class MockHttpService method registerServer.
public void registerServer() {
// Register services of test server
LOG.info("Registering service {}", serviceName);
cancelDiscovery = discoveryService.register(ResolvingDiscoverable.of(new Discoverable(serviceName, httpService.getBindAddress())));
}
use of org.apache.twill.discovery.Discoverable in project cdap by caskdata.
the class ServerResource method registerServer.
public void registerServer() {
// Register services of test server
LOG.info("Registering service {}", serviceName);
cancelDiscovery = discoveryService.register(ResolvingDiscoverable.of(new Discoverable(serviceName, httpService.getBindAddress())));
}
use of org.apache.twill.discovery.Discoverable in project cdap by caskdata.
the class ExternalAuthenticationServerTestBase method testServiceRegistration.
/**
* Test that the service is discoverable.
*
* @throws Exception
*/
@Test
public void testServiceRegistration() throws Exception {
Iterable<Discoverable> discoverables = discoveryServiceClient.discover(Constants.Service.EXTERNAL_AUTHENTICATION);
Set<SocketAddress> addresses = Sets.newHashSet();
for (Discoverable discoverable : discoverables) {
addresses.add(discoverable.getSocketAddress());
}
Assert.assertTrue(addresses.contains(server.getSocketAddress()));
}
use of org.apache.twill.discovery.Discoverable in project cdap by caskdata.
the class ResourceBalancerService method startUp.
@Override
protected void startUp() throws Exception {
LOG.info("Starting ResourceBalancer {} service...", serviceName);
// We first submit requirement before starting coordinator to make sure all needed paths in ZK are created
ResourceRequirement requirement = ResourceRequirement.builder(serviceName).addPartitions("", partitionCount, 1).build();
resourceClient.submitRequirement(requirement).get();
Discoverable discoverable = createDiscoverable(serviceName);
cancelDiscoverable = discoveryService.register(ResolvingDiscoverable.of(discoverable));
election.start();
resourceClient.startAndWait();
cancelResourceHandler = resourceClient.subscribe(serviceName, createResourceHandler(discoverable));
LOG.info("Started ResourceBalancer {} service...", serviceName);
}
use of org.apache.twill.discovery.Discoverable in project cdap by caskdata.
the class UpgradeTool method ensureCDAPMasterStopped.
/**
* Checks for appfabric service path on zookeeper, if they exist, CDAP master is still running, so throw
* exception message with information on where its running.
* @throws Exception if at least one master is running
*/
private void ensureCDAPMasterStopped() throws Exception {
String appFabricPath = String.format("/discoverable/%s", Constants.Service.APP_FABRIC_HTTP);
NodeChildren nodeChildren = zkClientService.getChildren(appFabricPath).get();
List<String> runningNodes = new ArrayList<>();
// if no children nodes at appfabric path, all master nodes are stopped
if (!nodeChildren.getChildren().isEmpty()) {
for (String runId : nodeChildren.getChildren()) {
// only one children would be present, as only the active master will be registered at this path
NodeData nodeData = zkClientService.getData(String.format("%s/%s", appFabricPath, runId)).get();
Discoverable discoverable = GSON.fromJson(Bytes.toString(nodeData.getData()), Discoverable.class);
runningNodes.add(discoverable.getSocketAddress().getHostName());
}
String exceptionMessage = String.format("CDAP Master is still running on %s, please stop it before running upgrade.", com.google.common.base.Joiner.on(",").join(runningNodes));
throw new Exception(exceptionMessage);
}
// CDAP-11733 As a future improvement, the upgrade tool can register as a CDAP master to become the leader
// and prevent other masters from starting.
}
Aggregations