@Override public boolean isRemoteBlobExists(String blobKey) throws AuthorizationException { try { return client.getClient().isRemoteBlobExists(blobKey); } catch (AuthorizationException aze) { throw aze; } catch (TException e) { throw new RuntimeException(e); } }
@Override public void cancel() throws IOException { try { synchronized (client) { client.getClient().cancelBlobUpload(session); } } catch (TException e) { throw new RuntimeException(e); } }
@Override public void write(int b) throws IOException { try { synchronized (client) { client.getClient().uploadBlobChunk(session, ByteBuffer.wrap(new byte[]{ (byte) b })); } } catch (TException e) { throw new RuntimeException(e); } }
@Override public void createStateInZookeeper(String key) { try { synchronized (client) { client.getClient().createStateInZookeeper(key); } } catch (TException e) { throw new RuntimeException(e); } }
@Override public int getBlobReplication(String key) throws AuthorizationException, KeyNotFoundException { try { return client.getClient().getBlobReplication(key); } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
@Override public ReadableBlobMeta getBlobMeta(String key) throws AuthorizationException, KeyNotFoundException { try { synchronized (client) { return client.getClient().getBlobMeta(key); } } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
@Override public void deleteBlob(String key) throws AuthorizationException, KeyNotFoundException { try { synchronized (client) { client.getClient().deleteBlob(key); } } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
@Override public int updateBlobReplication(String key, int replication) throws AuthorizationException, KeyNotFoundException { try { return client.getClient().updateBlobReplication(key, replication); } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
private static boolean topologyNameExists(String name, NimbusClient client) { try { return !client.getClient().isTopologyNameAllowed(name); } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected void setBlobMetaToExtend(String key, SettableBlobMeta meta) throws AuthorizationException, KeyNotFoundException { try { synchronized (client) { client.getClient().setBlobMeta(key, meta); } } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
public static TopologyInfo getTopologyInfo(String name, String asUser, Map<String, Object> topoConf) { try (NimbusClient client = NimbusClient.getConfiguredClientAs(topoConf, asUser)) { String topologyId = getTopologyId(name, client.getClient()); if (null != topologyId) { return client.getClient().getTopologyInfo(topologyId); } return null; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public InputStreamWithMeta getBlob(String key) throws AuthorizationException, KeyNotFoundException { try { synchronized (client) { return new NimbusDownloadInputStream(client.getClient().beginBlobDownload(key)); } } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
@Override public Iterator<String> listKeys() { try { synchronized (client) { return new NimbusKeyIterator(client.getClient().listBlobs("")); } } catch (TException e) { throw new RuntimeException(e); } }
@Override public AtomicOutputStream updateBlob(String key) throws AuthorizationException, KeyNotFoundException { try { synchronized (client) { return new NimbusUploadAtomicOutputStream(client.getClient().beginUpdateBlob(key), this.bufferSize, key); } } catch (AuthorizationException | KeyNotFoundException exp) { throw exp; } catch (TException e) { throw new RuntimeException(e); } }
/** * Execute cb with a configured nimbus client that will be closed once cb returns. * @param cb the callback to send to nimbus. * @param conf the conf to use instead of reading the global storm conf. * @throws Exception on any kind of error. */ public static void withConfiguredClient(WithNimbus cb, Map<String, Object> conf) throws Exception { try (NimbusClient client = getConfiguredClientAs(conf, null)) { cb.run(client.getClient()); } }
private void readMore() throws TException { if (!eof) { offset = 0; synchronized (client) { listBlobs = client.getClient().listBlobs(listBlobs.get_session()); } if (listBlobs.get_keys_size() == 0) { eof = true; } } }
@Override public void processWorkerMetrics(Map<String, Object> conf, WorkerMetrics metrics) throws MetricException { try (NimbusClient client = NimbusClient.getConfiguredClient(conf)) { client.getClient().processWorkerMetrics(metrics); } catch (TException | NimbusLeaderNotFoundException e) { throw new MetricException("Failed to process metrics", e); } }
public static void tryConnectAs(Map<String, Object> conf, ThriftServer server, Subject subject, String topoId) throws PrivilegedActionException { Subject.doAs(subject, (PrivilegedExceptionAction<Void>) () -> { try (NimbusClient client = new NimbusClient(conf, "localhost", server.getPort(), NIMBUS_TIMEOUT)) { client.getClient().activate(topoId); //Yes this should be a topo name, but it makes this simpler... } return null; }); }
public static void verifyIncorrectJaasConf(ThriftServer server, Map<String, Object> conf, String jaas, Class<? extends Exception> expectedException) { Map<String, Object> badConf = new HashMap<>(conf); badConf.put("java.security.auth.login.config", jaas); try (NimbusClient client = new NimbusClient(badConf, "localhost", server.getPort(), NIMBUS_TIMEOUT)) { client.getClient().activate("bad_auth_test_topology"); fail("An exception should have been thrown trying to connect."); } catch (Exception e) { LOG.info("Got Exception...", e); assert (Utils.exceptionCauseIsInstanceOf(expectedException, e)); } }