private boolean checkIfStateContainsCurrentNimbusHost(List<String> stateInfoList, NimbusInfo nimbusInfo) { boolean containsNimbusHost = false; for (String stateInfo : stateInfoList) { if (stateInfo.contains(nimbusInfo.getHost())) { containsNimbusHost = true; break; } } return containsNimbusHost; }
try (NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)) { rbm = client.getClient().getBlobMeta(key); remoteBlobStore = new NimbusBlobStore();
/** * If nimbusDetails are null, the method returns without any Zookeeper calls. */ @Test public void testUpdateKeyForBlobStore_nullNimbusInfo() { BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, null); zkClientBuilder.verifyExists(false); zkClientBuilder.verifyGetChildren(false); verify(nimbusDetails, never()).getHost(); verify(conf, never()).get(anyString()); }
public static void createStateInZookeeper(Map<String, Object> conf, String key, NimbusInfo nimbusInfo) throws TTransportException { ClientBlobStore cb = new NimbusBlobStore(); cb.setClient(conf, new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)); cb.createStateInZookeeper(key); }
/** * If the node has children, their hostnames will be checked and if they match, * downloadUpdatedBlob will not be called. */ @Test public void testUpdateKeyForBlobStore_hostsMatch() { zkClientBuilder.withExists(BLOBSTORE_KEY, true); zkClientBuilder.withGetChildren(BLOBSTORE_KEY, "localhost:1111-1"); when(nimbusDetails.getHost()).thenReturn("localhost"); BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, nimbusDetails); zkClientBuilder.verifyExists(true); zkClientBuilder.verifyGetChildren(2); verify(nimbusDetails).getHost(); verify(conf, never()).get(anyString()); }
/** * If the node has children, their hostnames will be checked and if they don't match, * downloadUpdatedBlob will be called. */ @Test public void testUpdateKeyForBlobStore_noMatch() { zkClientBuilder.withExists(BLOBSTORE_KEY, true); zkClientBuilder.withGetChildren(BLOBSTORE_KEY, "localhost:1111-1"); when(nimbusDetails.getHost()).thenReturn("no match"); BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, nimbusDetails); zkClientBuilder.verifyExists(true); zkClientBuilder.verifyGetChildren(2); verify(nimbusDetails).getHost(); verify(conf, atLeastOnce()).get(anyString()); } }
/** * If the node doesn't exist, the method returns before attempting to fetch children. */ @Test public void testUpdateKeyForBlobStore_missingNode() { zkClientBuilder.withExists(BLOBSTORE_KEY, false); BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, nimbusDetails); zkClientBuilder.verifyExists(true); zkClientBuilder.verifyGetChildren(false); verify(nimbusDetails, never()).getHost(); verify(conf, never()).get(anyString()); }
/** * If the node has null children, the method will exit before calling downloadUpdatedBlob * (the config map is first accessed by downloadUpdatedBlob). */ @Test public void testUpdateKeyForBlobStore_nodeWithNullChildren() { zkClientBuilder.withExists(BLOBSTORE_KEY, true); zkClientBuilder.withGetChildren(BLOBSTORE_KEY, (List<String>) null); BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, nimbusDetails); zkClientBuilder.verifyExists(true); zkClientBuilder.verifyGetChildren(); verify(nimbusDetails, never()).getHost(); verify(conf, never()).get(anyString()); }
/** * If the node has no children, the method behaves the same as for null children. */ @Test public void testUpdateKeyForBlobStore_nodeWithEmptyChildren() { zkClientBuilder.withExists(BLOBSTORE_KEY, true); zkClientBuilder.withGetChildren(BLOBSTORE_KEY); BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClientBuilder.build(), KEY, nimbusDetails); zkClientBuilder.verifyExists(true); zkClientBuilder.verifyGetChildren(); verify(nimbusDetails, never()).getHost(); verify(conf, never()).get(anyString()); }
@Override public NimbusSummary getLeader() throws AuthorizationException, TException { getLeaderCalls.mark(); checkAuthorization(null, null, "getClusterInfo"); List<NimbusSummary> nimbuses = stormClusterState.nimbuses(); NimbusInfo leader = leaderElector.getLeader(); for (NimbusSummary nimbusSummary : nimbuses) { if (leader.getHost().equals(nimbusSummary.get_host()) && leader.getPort() == nimbusSummary.get_port()) { nimbusSummary.set_uptime_secs(Time.deltaSecs(nimbusSummary.get_uptime_secs())); nimbusSummary.set_isLeader(true); return nimbusSummary; } } return null; }
break; try (NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)) { remoteBlobStore = new NimbusBlobStore(); remoteBlobStore.setClient(conf, client);
@Test public void testNimbodesWithLatestVersionOfBlob() throws Exception { try (TestingServer server = new TestingServer(); CuratorFramework zkClient = CuratorFrameworkFactory .newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3))) { zkClient.start(); // Creating nimbus hosts containing latest version of blob zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1"); zkClient.create().creatingParentContainersIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2"); Set<NimbusInfo> set = BlobStoreUtils.getNimbodesWithLatestSequenceNumberOfBlob(zkClient, "key1"); assertEquals("Failed to get the correct nimbus hosts with latest blob version", (set.iterator().next()).getHost(), "nimbus2"); zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus1:7800-1"); zkClient.delete().deletingChildrenIfNeeded().forPath("/blobstore/key1/nimbus2:7800-2"); } }
private boolean checkIfStateContainsCurrentNimbusHost(List<String> stateInfoList, NimbusInfo nimbusInfo) { boolean containsNimbusHost = false; for(String stateInfo:stateInfoList) { if(stateInfo.contains(nimbusInfo.getHost())) { containsNimbusHost = true; break; } } return containsNimbusHost; }
public static void createStateInZookeeper(Map conf, String key, NimbusInfo nimbusInfo) throws TTransportException { ClientBlobStore cb = new NimbusBlobStore(); cb.setClient(conf, new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)); cb.createStateInZookeeper(key); }
try(NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)) { rbm = client.getClient().getBlobMeta(key); remoteBlobStore = new NimbusBlobStore();
break; try(NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null)) { remoteBlobStore = new NimbusBlobStore(); remoteBlobStore.setClient(conf, client);