target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testInvalidUri2() throws JSONException, Exception { WebResource r = resource(); String responseStr = ""; try { responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class); fail("should have thrown exception on invalid uri"); } catch (UniformInterfaceException ue) { ClientResponse response = u... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testInvalidAccept() throws JSONException, Exception { WebResource r = resource(); String responseStr = ""; try { responseStr = r.path("ws").path("v1").path("cluster") .accept(MediaType.TEXT_PLAIN).get(String.class); fail("should have thrown exception on invalid uri"); } catch (UniformInterfaceExceptio... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testCluster() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.get... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterSlash() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster/") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = respon... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterDefault() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntity(JSONObject.class); ve... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testInfo() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("info").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = r... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testInfoSlash() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("info/").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject js... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testInfoDefault() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("info").get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntity(JSONObject.... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterMetrics() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("metrics").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONOb... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterMetricsSlash() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("metrics/").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); ... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterMetricsDefault() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("metrics").get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntit... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterMetricsXML() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("metrics").accept("application/xml").get(ClientResponse.class); assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); String xml = r... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterSchedulerFifo() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("scheduler").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType())... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterSchedulerFifoSlash() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("scheduler/").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getT... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterSchedulerFifoDefault() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("scheduler").get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test public void testClusterSchedulerFifoXML() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("scheduler").accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()... | @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); } | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... | RMWebServices { @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ClusterInfo get() { return getClusterInfo(); } @Inject RMWebServices(final ResourceManager rm,
final ApplicationACLsManager aclsManager); @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Clus... |
@Test(timeout=6000) public void testSleepWithoutInterrupt() throws InterruptedException { Thread sleeper = new Thread(new Runnable() { @Override public void run() { LOG.debug("Sleeper thread: sleeping for " + SLEEP_TIME_MS); Threads.sleepWithoutInterrupt(SLEEP_TIME_MS); LOG.debug("Sleeper thread: finished sleeping"); w... | public static void sleepWithoutInterrupt(final long msToWait) { long timeMillis = System.currentTimeMillis(); long endTime = timeMillis + msToWait; boolean interrupted = false; while (timeMillis < endTime) { try { Thread.sleep(endTime - timeMillis); } catch (InterruptedException ex) { interrupted = true; } timeMillis =... | Threads { public static void sleepWithoutInterrupt(final long msToWait) { long timeMillis = System.currentTimeMillis(); long endTime = timeMillis + msToWait; boolean interrupted = false; while (timeMillis < endTime) { try { Thread.sleep(endTime - timeMillis); } catch (InterruptedException ex) { interrupted = true; } ti... | Threads { public static void sleepWithoutInterrupt(final long msToWait) { long timeMillis = System.currentTimeMillis(); long endTime = timeMillis + msToWait; boolean interrupted = false; while (timeMillis < endTime) { try { Thread.sleep(endTime - timeMillis); } catch (InterruptedException ex) { interrupted = true; } ti... | Threads { public static void sleepWithoutInterrupt(final long msToWait) { long timeMillis = System.currentTimeMillis(); long endTime = timeMillis + msToWait; boolean interrupted = false; while (timeMillis < endTime) { try { Thread.sleep(endTime - timeMillis); } catch (InterruptedException ex) { interrupted = true; } ti... | Threads { public static void sleepWithoutInterrupt(final long msToWait) { long timeMillis = System.currentTimeMillis(); long endTime = timeMillis + msToWait; boolean interrupted = false; while (timeMillis < endTime) { try { Thread.sleep(endTime - timeMillis); } catch (InterruptedException ex) { interrupted = true; } ti... |
@Test public void testNodeHealthReportIsNotNull() throws Exception{ String host1 = "host1"; final int memory = 4 * 1024; org.apache.hadoop.yarn.server.resourcemanager.NodeManager nm1 = registerNode(host1, 1234, 2345, NetworkTopology.DEFAULT_RACK, memory); nm1.heartbeat(); nm1.heartbeat(); Collection<RMNode> values = re... | public RMContext getRMContext() { return this.rmContext; } | ResourceManager extends CompositeService implements Recoverable { public RMContext getRMContext() { return this.rmContext; } } | ResourceManager extends CompositeService implements Recoverable { public RMContext getRMContext() { return this.rmContext; } ResourceManager(); } | ResourceManager extends CompositeService implements Recoverable { public RMContext getRMContext() { return this.rmContext; } ResourceManager(); RMContext getRMContext(); @Override synchronized void init(Configuration conf); @Override void start(); @Override void stop(); @Private ClientRMService getClientRMService(); @P... | ResourceManager extends CompositeService implements Recoverable { public RMContext getRMContext() { return this.rmContext; } ResourceManager(); RMContext getRMContext(); @Override synchronized void init(Configuration conf); @Override void start(); @Override void stop(); @Private ClientRMService getClientRMService(); @P... |
@Test public void testRMAuditLoggerWithIP() throws Exception { Configuration conf = new Configuration(); Server server = RPC.getServer(TestProtocol.class, new MyTestRPCServer(), "0.0.0.0", 0, 5, true, conf, null); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); TestProtocol proxy = (TestPro... | static void start(Keys key, String value, StringBuilder b) { b.append(key.name()).append(AuditConstants.KEY_VAL_SEPARATOR).append(value); } | RMAuditLogger { static void start(Keys key, String value, StringBuilder b) { b.append(key.name()).append(AuditConstants.KEY_VAL_SEPARATOR).append(value); } } | RMAuditLogger { static void start(Keys key, String value, StringBuilder b) { b.append(key.name()).append(AuditConstants.KEY_VAL_SEPARATOR).append(value); } } | RMAuditLogger { static void start(Keys key, String value, StringBuilder b) { b.append(key.name()).append(AuditConstants.KEY_VAL_SEPARATOR).append(value); } static void logSuccess(String user, String operation, String target,
ApplicationId appId, ContainerId containerId); static void logSuccess(String user, Stri... | RMAuditLogger { static void start(Keys key, String value, StringBuilder b) { b.append(key.name()).append(AuditConstants.KEY_VAL_SEPARATOR).append(value); } static void logSuccess(String user, String operation, String target,
ApplicationId appId, ContainerId containerId); static void logSuccess(String user, Stri... |
@Test public void testGetClusterNodes() throws Exception { MockRM rm = new MockRM() { protected ClientRMService createClientRMService() { return new ClientRMService(this.rmContext, scheduler, this.rmAppManager, this.applicationACLsManager, this.rmDTSecretManager); }; }; rm.start(); MockNM node = rm.registerNode("host:1... | @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = this.rmContext.getRMNodes().values(); List<NodeReport> nodeReports = new Arr... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = th... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = th... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = th... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = th... |
@Test public void testGetApplicationReport() throws YarnRemoteException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null); RecordFactory recordFactory =... | @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnRemoteException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.getCurrentUser(); } catch (IOException ie) { LOG.info("Er... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnRemoteException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = User... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnRemoteException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = User... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnRemoteException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = User... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnRemoteException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = User... |
@Test public void testGetQueueInfo() throws Exception { YarnScheduler yarnScheduler = mock(YarnScheduler.class); RMContext rmContext = mock(RMContext.class); mockRMContext(yarnScheduler, rmContext); ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, null, null, null); GetQueueInfoRequest request ... | @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnRemoteException { GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); try { QueueInfo queueInfo = scheduler.getQueueInfo(request.getQueueName(), request.getIncludeChildQueues(), request.ge... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnRemoteException { GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); try { QueueInfo queueInfo = scheduler.getQue... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnRemoteException { GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); try { QueueInfo queueInfo = scheduler.getQue... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnRemoteException { GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); try { QueueInfo queueInfo = scheduler.getQue... | ClientRMService extends AbstractService implements
ClientRMProtocol { @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnRemoteException { GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); try { QueueInfo queueInfo = scheduler.getQue... |
@Test public void testFifoSchedulerCapacityWhenNoNMs() { FifoScheduler scheduler = new FifoScheduler(); QueueInfo queueInfo = scheduler.getQueueInfo(null, false, false); Assert.assertEquals(0.0f, queueInfo.getCurrentCapacity()); } | @Override public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues, boolean recursive) { return DEFAULT_QUEUE.getQueueInfo(false, false); } | FifoScheduler implements ResourceScheduler, Configurable { @Override public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues, boolean recursive) { return DEFAULT_QUEUE.getQueueInfo(false, false); } } | FifoScheduler implements ResourceScheduler, Configurable { @Override public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues, boolean recursive) { return DEFAULT_QUEUE.getQueueInfo(false, false); } } | FifoScheduler implements ResourceScheduler, Configurable { @Override public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues, boolean recursive) { return DEFAULT_QUEUE.getQueueInfo(false, false); } @Override synchronized void setConf(Configuration conf); @Override synchronized Configuration getConf(... | FifoScheduler implements ResourceScheduler, Configurable { @Override public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues, boolean recursive) { return DEFAULT_QUEUE.getQueueInfo(false, false); } @Override synchronized void setConf(Configuration conf); @Override synchronized Configuration getConf(... |
@Test public void testNormalizeRequest() { int minMemory = 1024; ResourceRequest ask = new ResourceRequestPBImpl(); ask.setCapability(Resource.createResource(-1024)); SchedulerUtils.normalizeRequest(ask, minMemory); assertEquals(minMemory, ask.getCapability().getMemory()); ask.setCapability(Resource.createResource(0));... | public static void normalizeRequest(ResourceRequest ask, int minMemory) { int memory = Math.max(ask.getCapability().getMemory(), minMemory); ask.getCapability().setMemory( minMemory * ((memory / minMemory) + (memory % minMemory > 0 ? 1 : 0))); } | SchedulerUtils { public static void normalizeRequest(ResourceRequest ask, int minMemory) { int memory = Math.max(ask.getCapability().getMemory(), minMemory); ask.getCapability().setMemory( minMemory * ((memory / minMemory) + (memory % minMemory > 0 ? 1 : 0))); } } | SchedulerUtils { public static void normalizeRequest(ResourceRequest ask, int minMemory) { int memory = Math.max(ask.getCapability().getMemory(), minMemory); ask.getCapability().setMemory( minMemory * ((memory / minMemory) + (memory % minMemory > 0 ? 1 : 0))); } } | SchedulerUtils { public static void normalizeRequest(ResourceRequest ask, int minMemory) { int memory = Math.max(ask.getCapability().getMemory(), minMemory); ask.getCapability().setMemory( minMemory * ((memory / minMemory) + (memory % minMemory > 0 ? 1 : 0))); } static ContainerStatus createAbnormalContainerStatus(
... | SchedulerUtils { public static void normalizeRequest(ResourceRequest ask, int minMemory) { int memory = Math.max(ask.getCapability().getMemory(), minMemory); ask.getCapability().setMemory( minMemory * ((memory / minMemory) + (memory % minMemory > 0 ? 1 : 0))); } static ContainerStatus createAbnormalContainerStatus(
... |
@Test public void testHierarchicalQueuesSimilarParents() { QueueManager queueManager = scheduler.getQueueManager(); FSLeafQueue leafQueue = queueManager.getLeafQueue("parent.child"); Assert.assertEquals(2, queueManager.getLeafQueues().size()); Assert.assertNotNull(leafQueue); Assert.assertEquals("root.parent.child", le... | public QueueManager getQueueManager() { return queueMgr; } | FairScheduler implements ResourceScheduler { public QueueManager getQueueManager() { return queueMgr; } } | FairScheduler implements ResourceScheduler { public QueueManager getQueueManager() { return queueMgr; } FairScheduler(); } | FairScheduler implements ResourceScheduler { public QueueManager getQueueManager() { return queueMgr; } FairScheduler(); FairSchedulerConfiguration getConf(); QueueManager getQueueManager(); RMContainerTokenSecretManager getContainerTokenSecretManager(); synchronized double getAppWeight(AppSchedulable app); @Override R... | FairScheduler implements ResourceScheduler { public QueueManager getQueueManager() { return queueMgr; } FairScheduler(); FairSchedulerConfiguration getConf(); QueueManager getQueueManager(); RMContainerTokenSecretManager getContainerTokenSecretManager(); synchronized double getAppWeight(AppSchedulable app); @Override R... |
@Test public void testIsStarvedForMinShare() throws Exception { Configuration conf = createConfiguration(); conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); scheduler.reinitialize(conf, resourceManager.getRMContext()); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml ve... | boolean isStarvedForMinShare(FSLeafQueue sched) { Resource desiredShare = Resources.min(sched.getMinShare(), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredShare); } | FairScheduler implements ResourceScheduler { boolean isStarvedForMinShare(FSLeafQueue sched) { Resource desiredShare = Resources.min(sched.getMinShare(), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredShare); } } | FairScheduler implements ResourceScheduler { boolean isStarvedForMinShare(FSLeafQueue sched) { Resource desiredShare = Resources.min(sched.getMinShare(), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredShare); } FairScheduler(); } | FairScheduler implements ResourceScheduler { boolean isStarvedForMinShare(FSLeafQueue sched) { Resource desiredShare = Resources.min(sched.getMinShare(), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredShare); } FairScheduler(); FairSchedulerConfiguration getConf(); QueueManager getQueueM... | FairScheduler implements ResourceScheduler { boolean isStarvedForMinShare(FSLeafQueue sched) { Resource desiredShare = Resources.min(sched.getMinShare(), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredShare); } FairScheduler(); FairSchedulerConfiguration getConf(); QueueManager getQueueM... |
@Test public void testIsStarvedForFairShare() throws Exception { Configuration conf = createConfiguration(); conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); scheduler.reinitialize(conf, resourceManager.getRMContext()); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml v... | boolean isStarvedForFairShare(FSLeafQueue sched) { Resource desiredFairShare = Resources.max( Resources.multiply(sched.getFairShare(), .5), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredFairShare); } | FairScheduler implements ResourceScheduler { boolean isStarvedForFairShare(FSLeafQueue sched) { Resource desiredFairShare = Resources.max( Resources.multiply(sched.getFairShare(), .5), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredFairShare); } } | FairScheduler implements ResourceScheduler { boolean isStarvedForFairShare(FSLeafQueue sched) { Resource desiredFairShare = Resources.max( Resources.multiply(sched.getFairShare(), .5), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredFairShare); } FairScheduler(); } | FairScheduler implements ResourceScheduler { boolean isStarvedForFairShare(FSLeafQueue sched) { Resource desiredFairShare = Resources.max( Resources.multiply(sched.getFairShare(), .5), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredFairShare); } FairScheduler(); FairSchedulerConfiguratio... | FairScheduler implements ResourceScheduler { boolean isStarvedForFairShare(FSLeafQueue sched) { Resource desiredFairShare = Resources.max( Resources.multiply(sched.getFairShare(), .5), sched.getDemand()); return Resources.lessThan(sched.getResourceUsage(), desiredFairShare); } FairScheduler(); FairSchedulerConfiguratio... |
@Test public void testUpdateDemand() { AppSchedulable app = mock(AppSchedulable.class); Mockito.when(app.getDemand()).thenReturn(maxResource); schedulable.addAppSchedulable(app); schedulable.addAppSchedulable(app); schedulable.updateDemand(); assertTrue("Demand is greater than max allowed ", Resources.equals(schedulabl... | @Override public void updateDemand() { Resource maxRes = queueMgr.getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : appScheds) { sched.updateDemand(); Resource toAdd = sched.getDemand(); if (LOG.isDebugEnabled()) { LOG.debug("Counting resource from " + sched.getName() + " " +... | FSLeafQueue extends FSQueue { @Override public void updateDemand() { Resource maxRes = queueMgr.getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : appScheds) { sched.updateDemand(); Resource toAdd = sched.getDemand(); if (LOG.isDebugEnabled()) { LOG.debug("Counting resource fr... | FSLeafQueue extends FSQueue { @Override public void updateDemand() { Resource maxRes = queueMgr.getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : appScheds) { sched.updateDemand(); Resource toAdd = sched.getDemand(); if (LOG.isDebugEnabled()) { LOG.debug("Counting resource fr... | FSLeafQueue extends FSQueue { @Override public void updateDemand() { Resource maxRes = queueMgr.getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : appScheds) { sched.updateDemand(); Resource toAdd = sched.getDemand(); if (LOG.isDebugEnabled()) { LOG.debug("Counting resource fr... | FSLeafQueue extends FSQueue { @Override public void updateDemand() { Resource maxRes = queueMgr.getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : appScheds) { sched.updateDemand(); Resource toAdd = sched.getDemand(); if (LOG.isDebugEnabled()) { LOG.debug("Counting resource fr... |
@Test public void testLocalityLevelWithoutDelays() { Queue queue = Mockito.mock(Queue.class); Priority prio = Mockito.mock(Priority.class); Mockito.when(prio.getPriority()).thenReturn(1); ApplicationAttemptId applicationAttemptId = createAppAttemptId(1, 1); FSSchedulerApp schedulerApp = new FSSchedulerApp(applicationAt... | public synchronized NodeType getAllowedLocalityLevel(Priority priority, int numNodes, double nodeLocalityThreshold, double rackLocalityThreshold) { if (nodeLocalityThreshold > 1.0) { nodeLocalityThreshold = 1.0; } if (rackLocalityThreshold > 1.0) { rackLocalityThreshold = 1.0; } if (nodeLocalityThreshold < 0.0 || rackL... | FSSchedulerApp extends SchedulerApplication { public synchronized NodeType getAllowedLocalityLevel(Priority priority, int numNodes, double nodeLocalityThreshold, double rackLocalityThreshold) { if (nodeLocalityThreshold > 1.0) { nodeLocalityThreshold = 1.0; } if (rackLocalityThreshold > 1.0) { rackLocalityThreshold = 1... | FSSchedulerApp extends SchedulerApplication { public synchronized NodeType getAllowedLocalityLevel(Priority priority, int numNodes, double nodeLocalityThreshold, double rackLocalityThreshold) { if (nodeLocalityThreshold > 1.0) { nodeLocalityThreshold = 1.0; } if (rackLocalityThreshold > 1.0) { rackLocalityThreshold = 1... | FSSchedulerApp extends SchedulerApplication { public synchronized NodeType getAllowedLocalityLevel(Priority priority, int numNodes, double nodeLocalityThreshold, double rackLocalityThreshold) { if (nodeLocalityThreshold > 1.0) { nodeLocalityThreshold = 1.0; } if (rackLocalityThreshold > 1.0) { rackLocalityThreshold = 1... | FSSchedulerApp extends SchedulerApplication { public synchronized NodeType getAllowedLocalityLevel(Priority priority, int numNodes, double nodeLocalityThreshold, double rackLocalityThreshold) { if (nodeLocalityThreshold > 1.0) { nodeLocalityThreshold = 1.0; } if (rackLocalityThreshold > 1.0) { rackLocalityThreshold = 1... |
@Test(expected=IOException.class) public void testParseQueue() throws IOException { CapacityScheduler cs = new CapacityScheduler(); cs.setConf(new YarnConfiguration()); CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); setupQueueConfiguration(conf); conf.setQueues(CapacitySchedulerConfiguratio... | @Lock(CapacityScheduler.class) static CSQueue parseQueue( CapacitySchedulerContext csContext, CapacitySchedulerConfiguration conf, CSQueue parent, String queueName, Map<String, CSQueue> queues, Map<String, CSQueue> oldQueues, Comparator<CSQueue> queueComparator, Comparator<FiCaSchedulerApp> applicationComparator, Queue... | CapacityScheduler implements ResourceScheduler, CapacitySchedulerContext, Configurable { @Lock(CapacityScheduler.class) static CSQueue parseQueue( CapacitySchedulerContext csContext, CapacitySchedulerConfiguration conf, CSQueue parent, String queueName, Map<String, CSQueue> queues, Map<String, CSQueue> oldQueues, Compa... | CapacityScheduler implements ResourceScheduler, CapacitySchedulerContext, Configurable { @Lock(CapacityScheduler.class) static CSQueue parseQueue( CapacitySchedulerContext csContext, CapacitySchedulerConfiguration conf, CSQueue parent, String queueName, Map<String, CSQueue> queues, Map<String, CSQueue> oldQueues, Compa... | CapacityScheduler implements ResourceScheduler, CapacitySchedulerContext, Configurable { @Lock(CapacityScheduler.class) static CSQueue parseQueue( CapacitySchedulerContext csContext, CapacitySchedulerConfiguration conf, CSQueue parent, String queueName, Map<String, CSQueue> queues, Map<String, CSQueue> oldQueues, Compa... | CapacityScheduler implements ResourceScheduler, CapacitySchedulerContext, Configurable { @Lock(CapacityScheduler.class) static CSQueue parseQueue( CapacitySchedulerContext csContext, CapacitySchedulerConfiguration conf, CSQueue parent, String queueName, Map<String, CSQueue> queues, Map<String, CSQueue> oldQueues, Compa... |
@Test public void testUserQueueAcl() throws Exception { LeafQueue d = stubLeafQueue((LeafQueue) queues.get(D)); final String user_d = "user_d"; final ApplicationAttemptId appAttemptId_0 = TestUtils .getMockApplicationAttemptId(0, 1); FiCaSchedulerApp app_0 = new FiCaSchedulerApp(appAttemptId_0, user_d, d, null, rmConte... | @Override public void submitApplication(FiCaSchedulerApp application, String userName, String queue) throws AccessControlException { UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName); if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) { throw new AccessControlException("User " + userNam... | LeafQueue implements CSQueue { @Override public void submitApplication(FiCaSchedulerApp application, String userName, String queue) throws AccessControlException { UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName); if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) { throw new AccessCon... | LeafQueue implements CSQueue { @Override public void submitApplication(FiCaSchedulerApp application, String userName, String queue) throws AccessControlException { UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName); if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) { throw new AccessCon... | LeafQueue implements CSQueue { @Override public void submitApplication(FiCaSchedulerApp application, String userName, String queue) throws AccessControlException { UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName); if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) { throw new AccessCon... | LeafQueue implements CSQueue { @Override public void submitApplication(FiCaSchedulerApp application, String userName, String queue) throws AccessControlException { UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName); if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) { throw new AccessCon... |
@Test public void testSingleLevelQueues() throws Exception { setupSingleLevelQueues(csConf); Map<String, CSQueue> queues = new HashMap<String, CSQueue>(); CSQueue root = CapacityScheduler.parseQueue(csContext, csConf, null, CapacitySchedulerConfiguration.ROOT, queues, queues, CapacityScheduler.queueComparator, Capacity... | @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assign containers to child-queue of " ... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... |
@Test public void testOffSwitchScheduling() throws Exception { setupSingleLevelQueues(csConf); Map<String, CSQueue> queues = new HashMap<String, CSQueue>(); CSQueue root = CapacityScheduler.parseQueue(csContext, csConf, null, CapacitySchedulerConfiguration.ROOT, queues, queues, CapacityScheduler.queueComparator, Capaci... | @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assign containers to child-queue of " ... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... |
@Test public void testOffSwitchSchedulingMultiLevelQueues() throws Exception { setupMultiLevelQueues(csConf); Map<String, CSQueue> queues = new HashMap<String, CSQueue>(); CSQueue root = CapacityScheduler.parseQueue(csContext, csConf, null, CapacitySchedulerConfiguration.ROOT, queues, queues, CapacityScheduler.queueCom... | @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assign containers to child-queue of " ... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... | ParentQueue implements CSQueue { @Override public synchronized CSAssignment assignContainers( Resource clusterResource, FiCaSchedulerNode node) { CSAssignment assignment = new CSAssignment(Resources.createResource(0), NodeType.NODE_LOCAL); while (canAssign(node)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to assig... |
@Test public void testGetPathApplicationId() { assertEquals("/proxy/application_100_0001", ProxyUriUtils.getPath(BuilderUtils.newApplicationId(100l, 1))); assertEquals("/proxy/application_6384623_0005", ProxyUriUtils.getPath(BuilderUtils.newApplicationId(6384623l, 5))); } | public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... |
@Test public void testConsistencyWithHadoopVLong() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (long l : testNumbers) { baos.reset(); ByteBuffer b = ByteBuffer.allocate(MAX_VLONG_LENGTH); ByteBufferUtils.writeVLong(b, l); String b... | public static void writeVLong(ByteBuffer out, long i) { if (i >= -112 && i <= 127) { out.put((byte) i); return; } int len = -112; if (i < 0) { i ^= -1L; len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } out.put((byte) len); len = (len < -120) ? -(len + 120) : -(len + 112); for (int idx = len; idx ... | ByteBufferUtils { public static void writeVLong(ByteBuffer out, long i) { if (i >= -112 && i <= 127) { out.put((byte) i); return; } int len = -112; if (i < 0) { i ^= -1L; len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } out.put((byte) len); len = (len < -120) ? -(len + 120) : -(len + 112); for (i... | ByteBufferUtils { public static void writeVLong(ByteBuffer out, long i) { if (i >= -112 && i <= 127) { out.put((byte) i); return; } int len = -112; if (i < 0) { i ^= -1L; len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } out.put((byte) len); len = (len < -120) ? -(len + 120) : -(len + 112); for (i... | ByteBufferUtils { public static void writeVLong(ByteBuffer out, long i) { if (i >= -112 && i <= 127) { out.put((byte) i); return; } int len = -112; if (i < 0) { i ^= -1L; len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } out.put((byte) len); len = (len < -120) ? -(len + 120) : -(len + 112); for (i... | ByteBufferUtils { public static void writeVLong(ByteBuffer out, long i) { if (i >= -112 && i <= 127) { out.put((byte) i); return; } int len = -112; if (i < 0) { i ^= -1L; len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } out.put((byte) len); len = (len < -120) ? -(len + 120) : -(len + 112); for (i... |
@Test(expected = IllegalArgumentException.class) public void testGetPathApplicationIdBad() { ProxyUriUtils.getPath(null); } | public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... |
@Test public void testGetPathApplicationIdString() { assertEquals("/proxy/application_6384623_0005", ProxyUriUtils.getPath(BuilderUtils.newApplicationId(6384623l, 5), null)); assertEquals("/proxy/application_6384623_0005/static/app", ProxyUriUtils.getPath(BuilderUtils.newApplicationId(6384623l, 5), "/static/app")); ass... | public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } } | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... | ProxyUriUtils { public static String getPath(ApplicationId id) { if(id == null) { throw new IllegalArgumentException("Application id cannot be null "); } return ujoin(PROXY_BASE, uriEncode(id)); } static String getPath(ApplicationId id); static String getPath(ApplicationId id, String path); static String getPathAndQue... |
@Test public void testGetPathAndQuery() { assertEquals("/proxy/application_6384623_0005/static/app?foo=bar", ProxyUriUtils.getPathAndQuery(BuilderUtils.newApplicationId(6384623l, 5), "/static/app", "?foo=bar", false)); assertEquals("/proxy/application_6384623_0005/static/app?foo=bar&bad=good&proxyapproved=true", ProxyU... | public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) { StringBuilder newp = new StringBuilder(); newp.append(getPath(id, path)); boolean first = appendQuery(newp, query, true); if(approved) { appendQuery(newp, PROXY_APPROVAL_PARAM+"=true", first); } return newp.toString();... | ProxyUriUtils { public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) { StringBuilder newp = new StringBuilder(); newp.append(getPath(id, path)); boolean first = appendQuery(newp, query, true); if(approved) { appendQuery(newp, PROXY_APPROVAL_PARAM+"=true", first); } return ... | ProxyUriUtils { public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) { StringBuilder newp = new StringBuilder(); newp.append(getPath(id, path)); boolean first = appendQuery(newp, query, true); if(approved) { appendQuery(newp, PROXY_APPROVAL_PARAM+"=true", first); } return ... | ProxyUriUtils { public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) { StringBuilder newp = new StringBuilder(); newp.append(getPath(id, path)); boolean first = appendQuery(newp, query, true); if(approved) { appendQuery(newp, PROXY_APPROVAL_PARAM+"=true", first); } return ... | ProxyUriUtils { public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) { StringBuilder newp = new StringBuilder(); newp.append(getPath(id, path)); boolean first = appendQuery(newp, query, true); if(approved) { appendQuery(newp, PROXY_APPROVAL_PARAM+"=true", first); } return ... |
@Test public void testGetProxyUri() throws Exception { URI originalUri = new URI("http: URI proxyUri = new URI("http: ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5); URI expected = new URI("http: URI result = ProxyUriUtils.getProxyUri(originalUri, proxyUri, id); assertEquals(expected, result); } | public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == null ? null : origi... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... |
@Test public void testGetProxyUriNull() throws Exception { URI originalUri = null; URI proxyUri = new URI("http: ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5); URI expected = new URI("http: URI result = ProxyUriUtils.getProxyUri(originalUri, proxyUri, id); assertEquals(expected, result); } | public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == null ? null : origi... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... | ProxyUriUtils { public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) { try { String path = getPath(id, originalUri == null ? "/" : originalUri.getPath()); return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == nul... |
@Test public void testGetProxyUriFromPluginsReturnsNullIfNoPlugins() throws URISyntaxException { ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5); List<TrackingUriPlugin> list = Lists.newArrayListWithExpectedSize(0); assertNull(ProxyUriUtils.getUriFromTrackingPlugins(id, list)); } | public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } static St... | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } static St... |
@Test public void testGetProxyUriFromPluginsReturnsValidUriWhenAble() throws URISyntaxException { ApplicationId id = BuilderUtils.newApplicationId(6384623l, 5); List<TrackingUriPlugin> list = Lists.newArrayListWithExpectedSize(2); list.add(new TrackingUriPlugin() { public URI getTrackingUri(ApplicationId id) throws URI... | public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } } | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } static St... | ProxyUriUtils { public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException { URI toRet = null; for(TrackingUriPlugin plugin : trackingUriPlugins) { toRet = plugin.getTrackingUri(id); if (toRet != null) { return toRet; } } return null; } static St... |
@Test public void testRules() throws Exception { checkTranslation("omalley@" + KerberosTestUtils.getRealm(), "omalley"); checkTranslation("hdfs/10.0.0.1@" + KerberosTestUtils.getRealm(), "hdfs"); checkTranslation("oom@YAHOO.COM", "oom"); checkTranslation("johndoe/zoo@FOO.COM", "guest"); checkTranslation("joe/admin@FOO.... | public String getRealm() { return realm; } | KerberosName { public String getRealm() { return realm; } } | KerberosName { public String getRealm() { return realm; } KerberosName(String name); } | KerberosName { public String getRealm() { return realm; } KerberosName(String name); String getDefaultRealm(); @Override String toString(); String getServiceName(); String getHostName(); String getRealm(); String getShortName(); static void setRules(String ruleString); static boolean hasRulesBeenSet(); } | KerberosName { public String getRealm() { return realm; } KerberosName(String name); String getDefaultRealm(); @Override String toString(); String getServiceName(); String getHostName(); String getRealm(); String getShortName(); static void setRules(String ruleString); static boolean hasRulesBeenSet(); } |
@Test public void testMoveBufferToStream() { final int arrayOffset = 7; final int initialPosition = 10; final int endPadding = 5; byte[] arrayWrapper = new byte[arrayOffset + initialPosition + array.length + endPadding]; System.arraycopy(array, 0, arrayWrapper, arrayOffset + initialPosition, array.length); ByteBuffer b... | public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException { copyBufferToStream(out, in, in.position(), length); skip(in, length); } | ByteBufferUtils { public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException { copyBufferToStream(out, in, in.position(), length); skip(in, length); } } | ByteBufferUtils { public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException { copyBufferToStream(out, in, in.position(), length); skip(in, length); } private ByteBufferUtils(); } | ByteBufferUtils { public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException { copyBufferToStream(out, in, in.position(), length); skip(in, length); } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readVLong(ByteBuffer in); static int p... | ByteBufferUtils { public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException { copyBufferToStream(out, in, in.position(), length); skip(in, length); } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readVLong(ByteBuffer in); static int p... |
@Test public void testLongHeader() throws Exception { URL url = new URL(baseUrl, "/longheader"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); StringBuilder sb = new StringBuilder(); for (int i = 0 ; i < 63 * 1024; i++) { sb.append("a"); } conn.setRequestProperty("longheader", sb.toString()); asser... | @Override public String toString() { return listener != null ? ("HttpServer at http: + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; } | HttpServer implements FilterContainer { @Override public String toString() { return listener != null ? ("HttpServer at http: + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; } } | HttpServer implements FilterContainer { @Override public String toString() { return listener != null ? ("HttpServer at http: + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; } HttpServer(String name, String bindAddress, int port, boolean findPort
); HttpServer(String... | HttpServer implements FilterContainer { @Override public String toString() { return listener != null ? ("HttpServer at http: + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; } HttpServer(String name, String bindAddress, int port, boolean findPort
); HttpServer(String... | HttpServer implements FilterContainer { @Override public String toString() { return listener != null ? ("HttpServer at http: + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; } HttpServer(String name, String bindAddress, int port, boolean findPort
); HttpServer(String... |
@Test public void testHasAdministratorAccess() throws Exception { Configuration conf = new Configuration(); conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false); ServletContext context = Mockito.mock(ServletContext.class); Mockito.when(context.getAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE)).th... | public static boolean hasAdministratorAccess( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws IOException { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); if (!conf.getBoolean( CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATIO... | HttpServer implements FilterContainer { public static boolean hasAdministratorAccess( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws IOException { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); if (!conf.getBoolean( CommonConfig... | HttpServer implements FilterContainer { public static boolean hasAdministratorAccess( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws IOException { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); if (!conf.getBoolean( CommonConfig... | HttpServer implements FilterContainer { public static boolean hasAdministratorAccess( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws IOException { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); if (!conf.getBoolean( CommonConfig... | HttpServer implements FilterContainer { public static boolean hasAdministratorAccess( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws IOException { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); if (!conf.getBoolean( CommonConfig... |
@Test public void testBulkOps() throws Exception { for (int type : CHECKSUM_TYPES) { System.err.println( "---- beginning tests with checksum type " + type + "----"); DataChecksum checksum = DataChecksum.newDataChecksum( type, BYTES_PER_CHUNK); for (boolean useDirect : new boolean[]{false, true}) { doBulkTest(checksum, ... | public static DataChecksum newDataChecksum( int type, int bytesPerChecksum ) { if ( bytesPerChecksum <= 0 ) { return null; } switch ( type ) { case CHECKSUM_NULL : return new DataChecksum( CHECKSUM_NULL, new ChecksumNull(), CHECKSUM_NULL_SIZE, bytesPerChecksum ); case CHECKSUM_CRC32 : return new DataChecksum( CHECKSUM_... | DataChecksum implements Checksum { public static DataChecksum newDataChecksum( int type, int bytesPerChecksum ) { if ( bytesPerChecksum <= 0 ) { return null; } switch ( type ) { case CHECKSUM_NULL : return new DataChecksum( CHECKSUM_NULL, new ChecksumNull(), CHECKSUM_NULL_SIZE, bytesPerChecksum ); case CHECKSUM_CRC32 :... | DataChecksum implements Checksum { public static DataChecksum newDataChecksum( int type, int bytesPerChecksum ) { if ( bytesPerChecksum <= 0 ) { return null; } switch ( type ) { case CHECKSUM_NULL : return new DataChecksum( CHECKSUM_NULL, new ChecksumNull(), CHECKSUM_NULL_SIZE, bytesPerChecksum ); case CHECKSUM_CRC32 :... | DataChecksum implements Checksum { public static DataChecksum newDataChecksum( int type, int bytesPerChecksum ) { if ( bytesPerChecksum <= 0 ) { return null; } switch ( type ) { case CHECKSUM_NULL : return new DataChecksum( CHECKSUM_NULL, new ChecksumNull(), CHECKSUM_NULL_SIZE, bytesPerChecksum ); case CHECKSUM_CRC32 :... | DataChecksum implements Checksum { public static DataChecksum newDataChecksum( int type, int bytesPerChecksum ) { if ( bytesPerChecksum <= 0 ) { return null; } switch ( type ) { case CHECKSUM_NULL : return new DataChecksum( CHECKSUM_NULL, new ChecksumNull(), CHECKSUM_NULL_SIZE, bytesPerChecksum ); case CHECKSUM_CRC32 :... |
@Test public void testToString() { assertEquals("DataChecksum(type=CRC32, chunkSize=512)", DataChecksum.newDataChecksum(DataChecksum.CHECKSUM_CRC32, 512) .toString()); } | @Override public String toString() { String strType = getNameOfType(type); return "DataChecksum(type=" + strType + ", chunkSize=" + bytesPerChecksum + ")"; } | DataChecksum implements Checksum { @Override public String toString() { String strType = getNameOfType(type); return "DataChecksum(type=" + strType + ", chunkSize=" + bytesPerChecksum + ")"; } } | DataChecksum implements Checksum { @Override public String toString() { String strType = getNameOfType(type); return "DataChecksum(type=" + strType + ", chunkSize=" + bytesPerChecksum + ")"; } private DataChecksum( int checksumType, Checksum checksum,
int sumSize, int chunkSize ); } | DataChecksum implements Checksum { @Override public String toString() { String strType = getNameOfType(type); return "DataChecksum(type=" + strType + ", chunkSize=" + bytesPerChecksum + ")"; } private DataChecksum( int checksumType, Checksum checksum,
int sumSize, int chunkSize ); static DataCh... | DataChecksum implements Checksum { @Override public String toString() { String strType = getNameOfType(type); return "DataChecksum(type=" + strType + ", chunkSize=" + bytesPerChecksum + ")"; } private DataChecksum( int checksumType, Checksum checksum,
int sumSize, int chunkSize ); static DataCh... |
@Test public void testRefreshHostFileReaderWithNonexistentFile() throws Exception { FileWriter efw = new FileWriter(excludesFile); FileWriter ifw = new FileWriter(includesFile); efw.close(); ifw.close(); HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile); assertTrue(INCLUDES_FILE.delete()); try { hfp... | public synchronized void refresh() throws IOException { LOG.info("Refreshing hosts (include/exclude) list"); if (!includesFile.equals("")) { Set<String> newIncludes = new HashSet<String>(); readFileToSet(includesFile, newIncludes); includes = newIncludes; } if (!excludesFile.equals("")) { Set<String> newExcludes = new ... | HostsFileReader { public synchronized void refresh() throws IOException { LOG.info("Refreshing hosts (include/exclude) list"); if (!includesFile.equals("")) { Set<String> newIncludes = new HashSet<String>(); readFileToSet(includesFile, newIncludes); includes = newIncludes; } if (!excludesFile.equals("")) { Set<String> ... | HostsFileReader { public synchronized void refresh() throws IOException { LOG.info("Refreshing hosts (include/exclude) list"); if (!includesFile.equals("")) { Set<String> newIncludes = new HashSet<String>(); readFileToSet(includesFile, newIncludes); includes = newIncludes; } if (!excludesFile.equals("")) { Set<String> ... | HostsFileReader { public synchronized void refresh() throws IOException { LOG.info("Refreshing hosts (include/exclude) list"); if (!includesFile.equals("")) { Set<String> newIncludes = new HashSet<String>(); readFileToSet(includesFile, newIncludes); includes = newIncludes; } if (!excludesFile.equals("")) { Set<String> ... | HostsFileReader { public synchronized void refresh() throws IOException { LOG.info("Refreshing hosts (include/exclude) list"); if (!includesFile.equals("")) { Set<String> newIncludes = new HashSet<String>(); readFileToSet(includesFile, newIncludes); includes = newIncludes; } if (!excludesFile.equals("")) { Set<String> ... |
@Test public void testCopyToStreamWithOffset() throws IOException { ByteBuffer buffer = ByteBuffer.wrap(array); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteBufferUtils.copyBufferToStream(bos, buffer, array.length / 2, array.length / 2); byte[] returnedArray = bos.toByteArray(); for (int i = 0; i < arra... | public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException { if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); } } } | ByteBufferUtils { public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException { if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); } } } } | ByteBufferUtils { public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException { if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); } } } private ByteBufferUtils()... | ByteBufferUtils { public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException { if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); } } } private ByteBufferUtils()... | ByteBufferUtils { public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException { if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); } } } private ByteBufferUtils()... |
@Test public void testEscapeString() throws Exception { assertEquals(NULL_STR, StringUtils.escapeString(NULL_STR)); assertEquals(EMPTY_STR, StringUtils.escapeString(EMPTY_STR)); assertEquals(STR_WO_SPECIAL_CHARS, StringUtils.escapeString(STR_WO_SPECIAL_CHARS)); assertEquals(ESCAPED_STR_WITH_COMMA, StringUtils.escapeStr... | public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); } | StringUtils { public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... | StringUtils { public static String escapeString(String str) { return escapeString(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... |
@Test public void testSplit() throws Exception { assertEquals(NULL_STR, StringUtils.split(NULL_STR)); String[] splits = StringUtils.split(EMPTY_STR); assertEquals(0, splits.length); splits = StringUtils.split(",,"); assertEquals(0, splits.length); splits = StringUtils.split(STR_WO_SPECIAL_CHARS); assertEquals(1, splits... | public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... objects)... | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... objects)... |
@Test public void testSimpleSplit() throws Exception { final String[] TO_TEST = { "a/b/c", "a/b/c " "", "/", " for (String testSubject : TO_TEST) { assertArrayEquals("Testing '" + testSubject + "'", testSubject.split("/"), StringUtils.split(testSubject, '/')); } } | public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... objects)... | StringUtils { public static String[] split(String str) { return split(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Object... objects)... |
@Test public void testUnescapeString() throws Exception { assertEquals(NULL_STR, StringUtils.unEscapeString(NULL_STR)); assertEquals(EMPTY_STR, StringUtils.unEscapeString(EMPTY_STR)); assertEquals(STR_WO_SPECIAL_CHARS, StringUtils.unEscapeString(STR_WO_SPECIAL_CHARS)); try { StringUtils.unEscapeString(STR_WITH_COMMA); ... | public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); } | StringUtils { public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); } } | StringUtils { public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Ob... | StringUtils { public static String unEscapeString(String str) { return unEscapeString(str, ESCAPE_CHAR, COMMA); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt(long number); static String format(final String format, final Ob... |
@Test public void testJoin() { List<String> s = new ArrayList<String>(); s.add("a"); s.add("b"); s.add("c"); assertEquals("", StringUtils.join(":", s.subList(0, 0))); assertEquals("a", StringUtils.join(":", s.subList(0, 1))); assertEquals("a:b", StringUtils.join(":", s.subList(0, 2))); assertEquals("a:b:c", StringUtils... | public static String join(CharSequence separator, Iterable<?> strings) { Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; } StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); } return sb.toString(); } | StringUtils { public static String join(CharSequence separator, Iterable<?> strings) { Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; } StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); } return sb.toString(); } } | StringUtils { public static String join(CharSequence separator, Iterable<?> strings) { Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; } StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); } return sb.toString(); } } | StringUtils { public static String join(CharSequence separator, Iterable<?> strings) { Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; } StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); } return sb.toString(); } st... | StringUtils { public static String join(CharSequence separator, Iterable<?> strings) { Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; } StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); } return sb.toString(); } st... |
@Test public void testGetTrimmedStrings() throws Exception { String compactDirList = "/spindle1/hdfs,/spindle2/hdfs,/spindle3/hdfs"; String spacedDirList = "/spindle1/hdfs, /spindle2/hdfs, /spindle3/hdfs"; String pathologicalDirList1 = " /spindle1/hdfs , /spindle2/hdfs ,/spindle3/hdfs "; String pathologicalDirList2 = "... | public static String[] getTrimmedStrings(String str){ if (null == str || "".equals(str.trim())) { return emptyStringArray; } return str.trim().split("\\s*,\\s*"); } | StringUtils { public static String[] getTrimmedStrings(String str){ if (null == str || "".equals(str.trim())) { return emptyStringArray; } return str.trim().split("\\s*,\\s*"); } } | StringUtils { public static String[] getTrimmedStrings(String str){ if (null == str || "".equals(str.trim())) { return emptyStringArray; } return str.trim().split("\\s*,\\s*"); } } | StringUtils { public static String[] getTrimmedStrings(String str){ if (null == str || "".equals(str.trim())) { return emptyStringArray; } return str.trim().split("\\s*,\\s*"); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt... | StringUtils { public static String[] getTrimmedStrings(String str){ if (null == str || "".equals(str.trim())) { return emptyStringArray; } return str.trim().split("\\s*,\\s*"); } static String stringifyException(Throwable e); static String simpleHostname(String fullHostname); @Deprecated static String humanReadableInt... |
@Test public void testCamelize() { assertEquals("Map", StringUtils.camelize("MAP")); assertEquals("JobSetup", StringUtils.camelize("JOB_SETUP")); assertEquals("SomeStuff", StringUtils.camelize("some_stuff")); assertEquals("Aa", StringUtils.camelize("aA")); assertEquals("Bb", StringUtils.camelize("bB")); assertEquals("C... | public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(s.toLowerCase(Locale.US), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang.StringUtils.capitalize(word)); return sb.toString(); } | StringUtils { public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(s.toLowerCase(Locale.US), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang.StringUtils.capitalize(word)); return sb.toString(); } } | StringUtils { public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(s.toLowerCase(Locale.US), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang.StringUtils.capitalize(word)); return sb.toString(); } } | StringUtils { public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(s.toLowerCase(Locale.US), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang.StringUtils.capitalize(word)); return sb.toString(); } static String stringifyException(Throwab... | StringUtils { public static String camelize(String s) { StringBuilder sb = new StringBuilder(); String[] words = split(s.toLowerCase(Locale.US), ESCAPE_CHAR, '_'); for (String word : words) sb.append(org.apache.commons.lang.StringUtils.capitalize(word)); return sb.toString(); } static String stringifyException(Throwab... |
@Test public void testStringToURI() { String[] str = new String[] { "file: try { StringUtils.stringToURI(str); fail("Ignoring URISyntaxException while creating URI from string file: } catch (IllegalArgumentException iae) { assertEquals("Failed to create uri for file: } } | public static URI[] stringToURI(String[] str){ if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length;i++){ try{ uris[i] = new URI(str[i]); }catch(URISyntaxException ur){ throw new IllegalArgumentException( "Failed to create uri for " + str[i], ur); } } return uris; } | StringUtils { public static URI[] stringToURI(String[] str){ if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length;i++){ try{ uris[i] = new URI(str[i]); }catch(URISyntaxException ur){ throw new IllegalArgumentException( "Failed to create uri for " + str[i], ur); } } return uris;... | StringUtils { public static URI[] stringToURI(String[] str){ if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length;i++){ try{ uris[i] = new URI(str[i]); }catch(URISyntaxException ur){ throw new IllegalArgumentException( "Failed to create uri for " + str[i], ur); } } return uris;... | StringUtils { public static URI[] stringToURI(String[] str){ if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length;i++){ try{ uris[i] = new URI(str[i]); }catch(URISyntaxException ur){ throw new IllegalArgumentException( "Failed to create uri for " + str[i], ur); } } return uris;... | StringUtils { public static URI[] stringToURI(String[] str){ if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length;i++){ try{ uris[i] = new URI(str[i]); }catch(URISyntaxException ur){ throw new IllegalArgumentException( "Failed to create uri for " + str[i], ur); } } return uris;... |
@Test public void testCopyFromStream() throws IOException { ByteBuffer buffer = ByteBuffer.allocate(array.length); ByteArrayInputStream bis = new ByteArrayInputStream(array); DataInputStream dis = new DataInputStream(bis); ByteBufferUtils.copyFromStreamToBuffer(buffer, dis, array.length / 2); ByteBufferUtils.copyFromSt... | public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException { if (out.hasArray()) { in.readFully(out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.readByte()); } } } | ByteBufferUtils { public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException { if (out.hasArray()) { in.readFully(out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.readByte()); } } } } | ByteBufferUtils { public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException { if (out.hasArray()) { in.readFully(out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.readByte()); } } } priva... | ByteBufferUtils { public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException { if (out.hasArray()) { in.readFully(out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.readByte()); } } } priva... | ByteBufferUtils { public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException { if (out.hasArray()) { in.readFully(out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.readByte()); } } } priva... |
@Test public void testSimpleHostName() { assertEquals("Should return hostname when FQDN is specified", "hadoop01", StringUtils.simpleHostname("hadoop01.domain.com")); assertEquals("Should return hostname when only hostname is specified", "hadoop01", StringUtils.simpleHostname("hadoop01")); assertEquals("Should not trun... | public static String simpleHostname(String fullHostname) { if (InetAddresses.isInetAddress(fullHostname)) { return fullHostname; } int offset = fullHostname.indexOf('.'); if (offset != -1) { return fullHostname.substring(0, offset); } return fullHostname; } | StringUtils { public static String simpleHostname(String fullHostname) { if (InetAddresses.isInetAddress(fullHostname)) { return fullHostname; } int offset = fullHostname.indexOf('.'); if (offset != -1) { return fullHostname.substring(0, offset); } return fullHostname; } } | StringUtils { public static String simpleHostname(String fullHostname) { if (InetAddresses.isInetAddress(fullHostname)) { return fullHostname; } int offset = fullHostname.indexOf('.'); if (offset != -1) { return fullHostname.substring(0, offset); } return fullHostname; } } | StringUtils { public static String simpleHostname(String fullHostname) { if (InetAddresses.isInetAddress(fullHostname)) { return fullHostname; } int offset = fullHostname.indexOf('.'); if (offset != -1) { return fullHostname.substring(0, offset); } return fullHostname; } static String stringifyException(Throwable e); ... | StringUtils { public static String simpleHostname(String fullHostname) { if (InetAddresses.isInetAddress(fullHostname)) { return fullHostname; } int offset = fullHostname.indexOf('.'); if (offset != -1) { return fullHostname.substring(0, offset); } return fullHostname; } static String stringifyException(Throwable e); ... |
@Test public void testCompareVersions() { assertEquals(0, VersionUtil.compareVersions("2.0.0", "2.0.0")); assertEquals(0, VersionUtil.compareVersions("2.0.0a", "2.0.0a")); assertEquals(0, VersionUtil.compareVersions("1", "1")); assertEquals(0, VersionUtil.compareVersions( "2.0.0-SNAPSHOT", "2.0.0-SNAPSHOT")); assertExp... | public static int compareVersions(String version1, String version2) { boolean isSnapshot1 = version1.endsWith(SNAPSHOT_SUFFIX); boolean isSnapshot2 = version2.endsWith(SNAPSHOT_SUFFIX); version1 = stripSnapshotSuffix(version1); version2 = stripSnapshotSuffix(version2); String[] version1Parts = version1.split("\\."); St... | VersionUtil { public static int compareVersions(String version1, String version2) { boolean isSnapshot1 = version1.endsWith(SNAPSHOT_SUFFIX); boolean isSnapshot2 = version2.endsWith(SNAPSHOT_SUFFIX); version1 = stripSnapshotSuffix(version1); version2 = stripSnapshotSuffix(version2); String[] version1Parts = version1.sp... | VersionUtil { public static int compareVersions(String version1, String version2) { boolean isSnapshot1 = version1.endsWith(SNAPSHOT_SUFFIX); boolean isSnapshot2 = version2.endsWith(SNAPSHOT_SUFFIX); version1 = stripSnapshotSuffix(version1); version2 = stripSnapshotSuffix(version2); String[] version1Parts = version1.sp... | VersionUtil { public static int compareVersions(String version1, String version2) { boolean isSnapshot1 = version1.endsWith(SNAPSHOT_SUFFIX); boolean isSnapshot2 = version2.endsWith(SNAPSHOT_SUFFIX); version1 = stripSnapshotSuffix(version1); version2 = stripSnapshotSuffix(version2); String[] version1Parts = version1.sp... | VersionUtil { public static int compareVersions(String version1, String version2) { boolean isSnapshot1 = version1.endsWith(SNAPSHOT_SUFFIX); boolean isSnapshot2 = version2.endsWith(SNAPSHOT_SUFFIX); version1 = stripSnapshotSuffix(version1); version2 = stripSnapshotSuffix(version2); String[] version1Parts = version1.sp... |
@Test public void testNativeLibraryChecker() { ExitUtil.disableSystemExit(); NativeLibraryChecker.main(new String[] {"-h"}); expectExit(new String[] {"-a", "-h"}); expectExit(new String[] {"aaa"}); if (NativeCodeLoader.isNativeCodeLoaded()) { NativeLibraryChecker.main(new String[0]); } else { expectExit(new String[0]);... | public static void main(String[] args) { String usage = "NativeLibraryChecker [-a|-h]\n" + " -a use -a to check all libraries are available\n" + " by default just check hadoop library is available\n" + " exit with error code if check failed\n" + " -h print this message\n"; if (args.length > 1 || (args.length == 1 && !(... | NativeLibraryChecker { public static void main(String[] args) { String usage = "NativeLibraryChecker [-a|-h]\n" + " -a use -a to check all libraries are available\n" + " by default just check hadoop library is available\n" + " exit with error code if check failed\n" + " -h print this message\n"; if (args.length > 1 || ... | NativeLibraryChecker { public static void main(String[] args) { String usage = "NativeLibraryChecker [-a|-h]\n" + " -a use -a to check all libraries are available\n" + " by default just check hadoop library is available\n" + " exit with error code if check failed\n" + " -h print this message\n"; if (args.length > 1 || ... | NativeLibraryChecker { public static void main(String[] args) { String usage = "NativeLibraryChecker [-a|-h]\n" + " -a use -a to check all libraries are available\n" + " by default just check hadoop library is available\n" + " exit with error code if check failed\n" + " -h print this message\n"; if (args.length > 1 || ... | NativeLibraryChecker { public static void main(String[] args) { String usage = "NativeLibraryChecker [-a|-h]\n" + " -a use -a to check all libraries are available\n" + " by default just check hadoop library is available\n" + " exit with error code if check failed\n" + " -h print this message\n"; if (args.length > 1 || ... |
@Test public void testNativeCodeLoaded() { if (requireTestJni() == false) { LOG.info("TestNativeCodeLoader: libhadoop.so testing is not required."); return; } if (!NativeCodeLoader.isNativeCodeLoaded()) { fail("TestNativeCodeLoader: libhadoop.so testing was required, but " + "libhadoop.so was not loaded."); } LOG.info(... | public static boolean isNativeCodeLoaded() { return nativeCodeLoaded; } | NativeCodeLoader { public static boolean isNativeCodeLoaded() { return nativeCodeLoaded; } } | NativeCodeLoader { public static boolean isNativeCodeLoaded() { return nativeCodeLoaded; } } | NativeCodeLoader { public static boolean isNativeCodeLoaded() { return nativeCodeLoaded; } static boolean isNativeCodeLoaded(); static native boolean buildSupportsSnappy(); boolean getLoadNativeLibraries(Configuration conf); void setLoadNativeLibraries(Configuration conf,
boolean ... | NativeCodeLoader { public static boolean isNativeCodeLoaded() { return nativeCodeLoaded; } static boolean isNativeCodeLoaded(); static native boolean buildSupportsSnappy(); boolean getLoadNativeLibraries(Configuration conf); void setLoadNativeLibraries(Configuration conf,
boolean ... |
@Test(timeout=1000) public void testFindContainingJar() { String containingJar = ClassUtil.findContainingJar(Logger.class); Assert.assertNotNull("Containing jar not found for Logger", containingJar); File jarFile = new File(containingJar); Assert.assertTrue("Containing jar does not exist on file system", jarFile.exists... | public static String findContainingJar(Class clazz) { ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(url.getProto... | ClassUtil { public static String findContainingJar(Class clazz) { ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(... | ClassUtil { public static String findContainingJar(Class clazz) { ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(... | ClassUtil { public static String findContainingJar(Class clazz) { ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(... | ClassUtil { public static String findContainingJar(Class clazz) { ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(... |
@Test public void testCopyFromBuffer() { ByteBuffer srcBuffer = ByteBuffer.allocate(array.length); ByteBuffer dstBuffer = ByteBuffer.allocate(array.length); srcBuffer.put(array); ByteBufferUtils.copyFromBufferToBuffer(dstBuffer, srcBuffer, array.length / 2, array.length / 4); for (int i = 0; i < array.length / 4; ++i) ... | public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ... | ByteBufferUtils { public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i... | ByteBufferUtils { public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i... | ByteBufferUtils { public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i... | ByteBufferUtils { public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i... |
@Test public void testGetStargateVersionXML() throws IOException, JAXBException { Response response = client.get("/version", Constants.MIMETYPE_XML); assertTrue(response.getCode() == 200); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); VersionModel model = (VersionModel) context.createUnmarsh... | @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); Res... | VersionResource extends ResourceBase { @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } servlet... | VersionResource extends ResourceBase { @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } servlet... | VersionResource extends ResourceBase { @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } servlet... | VersionResource extends ResourceBase { @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } servlet... |
@Test public void testShortNameShell() throws BadFencingConfigurationException { NodeFencer fencer = setupFencer("shell(true)"); assertTrue(fencer.fence(MOCK_TARGET)); } | public boolean fence(HAServiceTarget fromSvc) { LOG.info("====== Beginning Service Fencing Process... ======"); int i = 0; for (FenceMethodWithArg method : methods) { LOG.info("Trying method " + (++i) + "/" + methods.size() +": " + method); try { if (method.method.tryFence(fromSvc, method.arg)) { LOG.info("====== Fenci... | NodeFencer { public boolean fence(HAServiceTarget fromSvc) { LOG.info("====== Beginning Service Fencing Process... ======"); int i = 0; for (FenceMethodWithArg method : methods) { LOG.info("Trying method " + (++i) + "/" + methods.size() +": " + method); try { if (method.method.tryFence(fromSvc, method.arg)) { LOG.info(... | NodeFencer { public boolean fence(HAServiceTarget fromSvc) { LOG.info("====== Beginning Service Fencing Process... ======"); int i = 0; for (FenceMethodWithArg method : methods) { LOG.info("Trying method " + (++i) + "/" + methods.size() +": " + method); try { if (method.method.tryFence(fromSvc, method.arg)) { LOG.info(... | NodeFencer { public boolean fence(HAServiceTarget fromSvc) { LOG.info("====== Beginning Service Fencing Process... ======"); int i = 0; for (FenceMethodWithArg method : methods) { LOG.info("Trying method " + (++i) + "/" + methods.size() +": " + method); try { if (method.method.tryFence(fromSvc, method.arg)) { LOG.info(... | NodeFencer { public boolean fence(HAServiceTarget fromSvc) { LOG.info("====== Beginning Service Fencing Process... ======"); int i = 0; for (FenceMethodWithArg method : methods) { LOG.info("Trying method " + (++i) + "/" + methods.size() +": " + method); try { if (method.method.tryFence(fromSvc, method.arg)) { LOG.info(... |
@Test public void testBasicSuccessFailure() { assertTrue(fencer.tryFence(TEST_TARGET, "echo")); assertFalse(fencer.tryFence(TEST_TARGET, "exit 1")); assertFalse(fencer.tryFence(TEST_TARGET, "xxxxxxxxxxxx")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test public void testIntFitsIn() { assertEquals(1, ByteBufferUtils.intFitsIn(0)); assertEquals(1, ByteBufferUtils.intFitsIn(1)); assertEquals(2, ByteBufferUtils.intFitsIn(1 << 8)); assertEquals(3, ByteBufferUtils.intFitsIn(1 << 16)); assertEquals(4, ByteBufferUtils.intFitsIn(-1)); assertEquals(4, ByteBufferUtils.intFi... | public static int intFitsIn(final int value) { if (value < 0) { return 4; } if (value < (1 << 2 * 8)) { if (value < (1 << 1 * 8)) { return 1; } return 2; } if (value <= (1 << 3 * 8)) { return 3; } return 4; } | ByteBufferUtils { public static int intFitsIn(final int value) { if (value < 0) { return 4; } if (value < (1 << 2 * 8)) { if (value < (1 << 1 * 8)) { return 1; } return 2; } if (value <= (1 << 3 * 8)) { return 3; } return 4; } } | ByteBufferUtils { public static int intFitsIn(final int value) { if (value < 0) { return 4; } if (value < (1 << 2 * 8)) { if (value < (1 << 1 * 8)) { return 1; } return 2; } if (value <= (1 << 3 * 8)) { return 3; } return 4; } private ByteBufferUtils(); } | ByteBufferUtils { public static int intFitsIn(final int value) { if (value < 0) { return 4; } if (value < (1 << 2 * 8)) { if (value < (1 << 1 * 8)) { return 1; } return 2; } if (value <= (1 << 3 * 8)) { return 3; } return 4; } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readV... | ByteBufferUtils { public static int intFitsIn(final int value) { if (value < 0) { return 4; } if (value < (1 << 2 * 8)) { if (value < (1 << 1 * 8)) { return 1; } return 2; } if (value <= (1 << 3 * 8)) { return 3; } return 4; } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readV... |
@Test public void testStdoutLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello")); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo hello: hello")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test public void testStderrLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello >&2")); Mockito.verify(ShellCommandFencer.LOG).warn( Mockito.endsWith("echo hello >&2: hello")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test public void testConfAsEnvironment() { fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $in...ing_tests: yessir")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test public void testTargetAsEnvironment() { fencer.tryFence(TEST_TARGET, "echo $target_host $target_port $target_address"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $ta...t_address: host 1234 host:1234")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test(timeout=10000) public void testSubprocessInputIsClosed() { assertFalse(fencer.tryFence(TEST_TARGET, "read")); } | @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p = builder.start(); p.getOutputStream().close(); } catch (IOExc... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... | ShellCommandFencer extends Configured implements FenceMethod { @Override public boolean tryFence(HAServiceTarget target, String cmd) { ProcessBuilder builder = new ProcessBuilder( "bash", "-e", "-c", cmd); setConfAsEnvVars(builder.environment()); addTargetInfoAsEnvVars(target, builder.environment()); Process p; try { p... |
@Test public void testEmptyACL() { List<ACL> result = HAZKUtil.parseACLs(""); assertTrue(result.isEmpty()); } | public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int lastColon ... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... |
@Test public void testNullACL() { List<ACL> result = HAZKUtil.parseACLs(null); assertTrue(result.isEmpty()); } | public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int lastColon ... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... |
@Test public void testGoodACLs() { List<ACL> result = HAZKUtil.parseACLs( "sasl:hdfs/host1@MY.DOMAIN:cdrwa, sasl:hdfs/host2@MY.DOMAIN:ca"); ACL acl0 = result.get(0); assertEquals(Perms.CREATE | Perms.DELETE | Perms.READ | Perms.WRITE | Perms.ADMIN, acl0.getPerms()); assertEquals("sasl", acl0.getId().getScheme()); asser... | public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int lastColon ... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... | HAZKUtil { public static List<ACL> parseACLs(String aclString) { List<ACL> acl = Lists.newArrayList(); if (aclString == null) { return acl; } List<String> aclComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(aclString)); for (String a : aclComps) { int firstColon = a.indexOf(':'); int... |
@Test public void testEmptyAuth() { List<ZKAuthInfo> result = HAZKUtil.parseAuth(""); assertTrue(result.isEmpty()); } | public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[] = comp.spl... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... |
@Test public void testLongFitsIn() { assertEquals(1, ByteBufferUtils.longFitsIn(0)); assertEquals(1, ByteBufferUtils.longFitsIn(1)); assertEquals(3, ByteBufferUtils.longFitsIn(1l << 16)); assertEquals(5, ByteBufferUtils.longFitsIn(1l << 32)); assertEquals(8, ByteBufferUtils.longFitsIn(-1)); assertEquals(8, ByteBufferUt... | public static int longFitsIn(final long value) { if (value < 0) { return 8; } if (value < (1l << 4 * 8)) { if (value < (1l << 2 * 8)) { if (value < (1l << 1 * 8)) { return 1; } return 2; } if (value < (1l << 3 * 8)) { return 3; } return 4; } if (value < (1l << 6 * 8)) { if (value < (1l << 5 * 8)) { return 5; } return 6... | ByteBufferUtils { public static int longFitsIn(final long value) { if (value < 0) { return 8; } if (value < (1l << 4 * 8)) { if (value < (1l << 2 * 8)) { if (value < (1l << 1 * 8)) { return 1; } return 2; } if (value < (1l << 3 * 8)) { return 3; } return 4; } if (value < (1l << 6 * 8)) { if (value < (1l << 5 * 8)) { re... | ByteBufferUtils { public static int longFitsIn(final long value) { if (value < 0) { return 8; } if (value < (1l << 4 * 8)) { if (value < (1l << 2 * 8)) { if (value < (1l << 1 * 8)) { return 1; } return 2; } if (value < (1l << 3 * 8)) { return 3; } return 4; } if (value < (1l << 6 * 8)) { if (value < (1l << 5 * 8)) { re... | ByteBufferUtils { public static int longFitsIn(final long value) { if (value < 0) { return 8; } if (value < (1l << 4 * 8)) { if (value < (1l << 2 * 8)) { if (value < (1l << 1 * 8)) { return 1; } return 2; } if (value < (1l << 3 * 8)) { return 3; } return 4; } if (value < (1l << 6 * 8)) { if (value < (1l << 5 * 8)) { re... | ByteBufferUtils { public static int longFitsIn(final long value) { if (value < 0) { return 8; } if (value < (1l << 4 * 8)) { if (value < (1l << 2 * 8)) { if (value < (1l << 1 * 8)) { return 1; } return 2; } if (value < (1l << 3 * 8)) { return 3; } return 4; } if (value < (1l << 6 * 8)) { if (value < (1l << 5 * 8)) { re... |
@Test public void testNullAuth() { List<ZKAuthInfo> result = HAZKUtil.parseAuth(null); assertTrue(result.isEmpty()); } | public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[] = comp.spl... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... |
@Test public void testGoodAuths() { List<ZKAuthInfo> result = HAZKUtil.parseAuth( "scheme:data,\n scheme2:user:pass"); assertEquals(2, result.size()); ZKAuthInfo auth0 = result.get(0); assertEquals("scheme", auth0.getScheme()); assertEquals("data", new String(auth0.getAuth())); ZKAuthInfo auth1 = result.get(1); assertE... | public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[] = comp.spl... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... | HAZKUtil { public static List<ZKAuthInfo> parseAuth(String authString) { List<ZKAuthInfo> ret = Lists.newArrayList(); if (authString == null) { return ret; } List<String> authComps = Lists.newArrayList( Splitter.on(',').omitEmptyStrings().trimResults() .split(authString)); for (String comp : authComps) { String parts[]... |
@Test public void testConfIndirection() throws IOException { assertNull(HAZKUtil.resolveConfIndirection(null)); assertEquals("x", HAZKUtil.resolveConfIndirection("x")); TEST_FILE.getParentFile().mkdirs(); Files.write("hello world", TEST_FILE, Charsets.UTF_8); assertEquals("hello world", HAZKUtil.resolveConfIndirection(... | public static String resolveConfIndirection(String valInConf) throws IOException { if (valInConf == null) return null; if (!valInConf.startsWith("@")) { return valInConf; } String path = valInConf.substring(1).trim(); return Files.toString(new File(path), Charsets.UTF_8).trim(); } | HAZKUtil { public static String resolveConfIndirection(String valInConf) throws IOException { if (valInConf == null) return null; if (!valInConf.startsWith("@")) { return valInConf; } String path = valInConf.substring(1).trim(); return Files.toString(new File(path), Charsets.UTF_8).trim(); } } | HAZKUtil { public static String resolveConfIndirection(String valInConf) throws IOException { if (valInConf == null) return null; if (!valInConf.startsWith("@")) { return valInConf; } String path = valInConf.substring(1).trim(); return Files.toString(new File(path), Charsets.UTF_8).trim(); } } | HAZKUtil { public static String resolveConfIndirection(String valInConf) throws IOException { if (valInConf == null) return null; if (!valInConf.startsWith("@")) { return valInConf; } String path = valInConf.substring(1).trim(); return Files.toString(new File(path), Charsets.UTF_8).trim(); } static List<ACL> parseACLs... | HAZKUtil { public static String resolveConfIndirection(String valInConf) throws IOException { if (valInConf == null) return null; if (!valInConf.startsWith("@")) { return valInConf; } String path = valInConf.substring(1).trim(); return Files.toString(new File(path), Charsets.UTF_8).trim(); } static List<ACL> parseACLs... |
@Test(expected = HadoopIllegalArgumentException.class) public void testJoinElectionException() { elector.joinElection(null); } | public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); return; } appData = new byte[data.length]; System.arraycopy(dat... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... |
@Test public void testJoinElection() { elector.joinElection(data); Mockito.verify(mockZK, Mockito.times(1)).create(ZK_LOCK_NAME, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, elector, mockZK); } | public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); return; } appData = new byte[data.length]; System.arraycopy(dat... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void joinElection(byte[] data) throws HadoopIllegalArgumentException { if (data == null) { throw new HadoopIllegalArgumentException("data cannot be null"); } if (wantToBeInElection) { LOG.info("Already in election. Not re-connecting."); ... |
@Test public void testQuitElection() throws Exception { elector.joinElection(data); Mockito.verify(mockZK, Mockito.times(0)).close(); elector.quitElection(true); Mockito.verify(mockZK, Mockito.times(1)).close(); verifyExistCall(0); byte[] data = new byte[8]; elector.joinElection(data); Assert.assertEquals(2, count); el... | public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } } | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } ActiveStandbyElector(String zookeeperHostPorts,
... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } ActiveStandbyElector(String zookeeperHostPorts,
... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } ActiveStandbyElector(String zookeeperHostPorts,
... |
@Test public void testGetActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { byte[] data = new byte[8]; Mockito.when( mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false), Mockito.<Stat> anyObject())).thenReturn(data); Assert.assertEquals(data, elector.getActiveData()... | public synchronized byte[] getActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { try { if (zkClient == null) { createConnection(); } Stat stat = new Stat(); return getDataWithRetries(zkLockFilePath, false, stat); } catch(KeeperException e) { Code code = e.code(); if (isNod... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized byte[] getActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { try { if (zkClient == null) { createConnection(); } Stat stat = new Stat(); return getDataWithRetries(zkLockFilePath, false, stat... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized byte[] getActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { try { if (zkClient == null) { createConnection(); } Stat stat = new Stat(); return getDataWithRetries(zkLockFilePath, false, stat... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized byte[] getActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { try { if (zkClient == null) { createConnection(); } Stat stat = new Stat(); return getDataWithRetries(zkLockFilePath, false, stat... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized byte[] getActiveData() throws ActiveNotFoundException, KeeperException, InterruptedException, IOException { try { if (zkClient == null) { createConnection(); } Stat stat = new Stat(); return getDataWithRetries(zkLockFilePath, false, stat... |
@Test public void testEnsureBaseNodeFails() throws Exception { Mockito.doThrow(new KeeperException.ConnectionLossException()) .when(mockZK).create( Mockito.eq(ZK_PARENT_NAME), Mockito.<byte[]>any(), Mockito.eq(Ids.OPEN_ACL_UNSAFE), Mockito.eq(CreateMode.PERSISTENT)); try { elector.ensureParentZNode(); Assert.fail("Did ... | public synchronized void ensureParentZNode() throws IOException, InterruptedException { Preconditions.checkState(!wantToBeInElection, "ensureParentZNode() may not be called while in the election"); String pathParts[] = znodeWorkingDir.split("/"); Preconditions.checkArgument(pathParts.length >= 1 && "".equals(pathParts[... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void ensureParentZNode() throws IOException, InterruptedException { Preconditions.checkState(!wantToBeInElection, "ensureParentZNode() may not be called while in the election"); String pathParts[] = znodeWorkingDir.split("/"); Preconditi... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void ensureParentZNode() throws IOException, InterruptedException { Preconditions.checkState(!wantToBeInElection, "ensureParentZNode() may not be called while in the election"); String pathParts[] = znodeWorkingDir.split("/"); Preconditi... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void ensureParentZNode() throws IOException, InterruptedException { Preconditions.checkState(!wantToBeInElection, "ensureParentZNode() may not be called while in the election"); String pathParts[] = znodeWorkingDir.split("/"); Preconditi... | ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void ensureParentZNode() throws IOException, InterruptedException { Preconditions.checkState(!wantToBeInElection, "ensureParentZNode() may not be called while in the election"); String pathParts[] = znodeWorkingDir.split("/"); Preconditi... |
@Test public void testBecomeActiveBeforeServiceHealthy() throws Exception { mockNoPriorActive(); WatchedEvent mockEvent = Mockito.mock(WatchedEvent.class); Mockito.when(mockEvent.getType()).thenReturn(Event.EventType.None); Mockito.when(mockEvent.getState()).thenReturn(Event.KeeperState.Expired); elector.processWatchEv... | synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) { Event.EventType eventType = event.getType(); if (isStaleClient(zk)) return; LOG.debug("Watcher event type: " + eventType + " with state:" + event.getState() + " for path:" + event.getPath() + " connectionState: " + zkConnectionState + " for " + thi... | ActiveStandbyElector implements StatCallback, StringCallback { synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) { Event.EventType eventType = event.getType(); if (isStaleClient(zk)) return; LOG.debug("Watcher event type: " + eventType + " with state:" + event.getState() + " for path:" + event.getPa... | ActiveStandbyElector implements StatCallback, StringCallback { synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) { Event.EventType eventType = event.getType(); if (isStaleClient(zk)) return; LOG.debug("Watcher event type: " + eventType + " with state:" + event.getState() + " for path:" + event.getPa... | ActiveStandbyElector implements StatCallback, StringCallback { synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) { Event.EventType eventType = event.getType(); if (isStaleClient(zk)) return; LOG.debug("Watcher event type: " + eventType + " with state:" + event.getState() + " for path:" + event.getPa... | ActiveStandbyElector implements StatCallback, StringCallback { synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) { Event.EventType eventType = event.getType(); if (isStaleClient(zk)) return; LOG.debug("Watcher event type: " + eventType + " with state:" + event.getState() + " for path:" + event.getPa... |
@Test public void testArePartEqual() { byte[] array = new byte[] { 1, 2, 3, 4, 5, 1, 2, 3, 4 }; ByteBuffer buffer = ByteBuffer.wrap(array); assertTrue(ByteBufferUtils.arePartsEqual(buffer, 0, 4, 5, 4)); assertTrue(ByteBufferUtils.arePartsEqual(buffer, 1, 2, 6, 2)); assertFalse(ByteBufferUtils.arePartsEqual(buffer, 1, 2... | public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight) { if (lengthLeft != lengthRight) { return false; } if (buffer.hasArray()) { return 0 == Bytes.compareTo( buffer.array(), buffer.arrayOffset() + offsetLeft, lengthLeft, buffer.array(), buffer.arrayOff... | ByteBufferUtils { public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight) { if (lengthLeft != lengthRight) { return false; } if (buffer.hasArray()) { return 0 == Bytes.compareTo( buffer.array(), buffer.arrayOffset() + offsetLeft, lengthLeft, buffer.array(... | ByteBufferUtils { public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight) { if (lengthLeft != lengthRight) { return false; } if (buffer.hasArray()) { return 0 == Bytes.compareTo( buffer.array(), buffer.arrayOffset() + offsetLeft, lengthLeft, buffer.array(... | ByteBufferUtils { public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight) { if (lengthLeft != lengthRight) { return false; } if (buffer.hasArray()) { return 0 == Bytes.compareTo( buffer.array(), buffer.arrayOffset() + offsetLeft, lengthLeft, buffer.array(... | ByteBufferUtils { public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight) { if (lengthLeft != lengthRight) { return false; } if (buffer.hasArray()) { return 0 == Bytes.compareTo( buffer.array(), buffer.arrayOffset() + offsetLeft, lengthLeft, buffer.array(... |
@Test public void testHelp() throws Exception { assertEquals(0, runTool("-help")); assertEquals(0, runTool("-help", "transitionToActive")); assertOutputContains("Transitions the service into Active"); } | private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageInfo == null) { errOut.println(cmd + ": Unknow... | HAAdmin extends Configured implements Tool { private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageI... | HAAdmin extends Configured implements Tool { private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageI... | HAAdmin extends Configured implements Tool { private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageI... | HAAdmin extends Configured implements Tool { private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageI... |
@Test(timeout=15000) public void testCallbackThrowsRTE() throws Exception { hm.addCallback(new Callback() { @Override public void enteredState(State newState) { throw new RuntimeException("Injected RTE"); } }); LOG.info("Mocking bad health check, waiting for UNHEALTHY"); svc.isHealthy = false; waitForState(hm, HealthMo... | public void addCallback(Callback cb) { this.callbacks.add(cb); } | HealthMonitor { public void addCallback(Callback cb) { this.callbacks.add(cb); } } | HealthMonitor { public void addCallback(Callback cb) { this.callbacks.add(cb); } HealthMonitor(Configuration conf, HAServiceTarget target); } | HealthMonitor { public void addCallback(Callback cb) { this.callbacks.add(cb); } HealthMonitor(Configuration conf, HAServiceTarget target); void addCallback(Callback cb); void removeCallback(Callback cb); void shutdown(); synchronized HAServiceProtocol getProxy(); } | HealthMonitor { public void addCallback(Callback cb) { this.callbacks.add(cb); } HealthMonitor(Configuration conf, HAServiceTarget target); void addCallback(Callback cb); void removeCallback(Callback cb); void shutdown(); synchronized HAServiceProtocol getProxy(); } |
@Test public void testCopyBytesShouldCloseStreamsWhenCloseIsTrue() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[1]); IOUtils.copyBytes(inputStream, outputStream, 1, true); ... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testCopyBytesShouldCloseInputSteamWhenOutputStreamCloseThrowsException() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[1]); Mockito.doThrow(new IOException... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testCopyBytesShouldNotCloseStreamsWhenCloseIsFalse() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[1]); IOUtils.copyBytes(inputStream, outputStream, 1, fal... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testPutInt() { testPutInt(0); testPutInt(Integer.MAX_VALUE); for (int i = 0; i < 3; i++) { testPutInt((128 << i) - 1); } for (int i = 0; i < 3; i++) { testPutInt((128 << i)); } } | public static void putInt(OutputStream out, final int value) throws IOException { for (int i = Bytes.SIZEOF_INT - 1; i >= 0; --i) { out.write((byte) (value >>> (i * 8))); } } | ByteBufferUtils { public static void putInt(OutputStream out, final int value) throws IOException { for (int i = Bytes.SIZEOF_INT - 1; i >= 0; --i) { out.write((byte) (value >>> (i * 8))); } } } | ByteBufferUtils { public static void putInt(OutputStream out, final int value) throws IOException { for (int i = Bytes.SIZEOF_INT - 1; i >= 0; --i) { out.write((byte) (value >>> (i * 8))); } } private ByteBufferUtils(); } | ByteBufferUtils { public static void putInt(OutputStream out, final int value) throws IOException { for (int i = Bytes.SIZEOF_INT - 1; i >= 0; --i) { out.write((byte) (value >>> (i * 8))); } } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readVLong(ByteBuffer in); static int pu... | ByteBufferUtils { public static void putInt(OutputStream out, final int value) throws IOException { for (int i = Bytes.SIZEOF_INT - 1; i >= 0; --i) { out.write((byte) (value >>> (i * 8))); } } private ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readVLong(ByteBuffer in); static int pu... |
@Test public void testCopyBytesWithCountShouldCloseStreamsWhenCloseIsTrue() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[4096], 0, 1); IOUtils.copyBytes(inputStream, output... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testCopyBytesWithCountShouldNotCloseStreamsWhenCloseIsFalse() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[4096], 0, 1); IOUtils.copyBytes(inputStream, ou... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testCopyBytesWithCountShouldThrowOutTheStreamClosureExceptions() throws Exception { InputStream inputStream = Mockito.mock(InputStream.class); OutputStream outputStream = Mockito.mock(OutputStream.class); Mockito.doReturn(-1).when(inputStream).read(new byte[4096], 0, 1); Mockito.doThrow(new IOExceptio... | public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } } | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... | IOUtils { public static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) throws IOException { try { copyBytes(in, out, buffSize); if(close) { out.close(); out = null; in.close(); in = null; } } finally { if(close) { closeStream(out); closeStream(in); } } } static void copyBytes(InputStream... |
@Test public void testWriteFully() throws IOException { final int INPUT_BUFFER_LEN = 10000; final int HALFWAY = 1 + (INPUT_BUFFER_LEN / 2); byte[] input = new byte[INPUT_BUFFER_LEN]; for (int i = 0; i < input.length; i++) { input[i] = (byte)(i & 0xff); } byte[] output = new byte[input.length]; try { RandomAccessFile ra... | public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException { do { bc.write(buf); } while (buf.remaining() > 0); } | IOUtils { public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException { do { bc.write(buf); } while (buf.remaining() > 0); } } | IOUtils { public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException { do { bc.write(buf); } while (buf.remaining() > 0); } } | IOUtils { public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException { do { bc.write(buf); } while (buf.remaining() > 0); } static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close); static void copyBytes(InputStream in, OutputStream out, int buffSize); static v... | IOUtils { public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException { do { bc.write(buf); } while (buf.remaining() > 0); } static void copyBytes(InputStream in, OutputStream out, int buffSize, boolean close); static void copyBytes(InputStream in, OutputStream out, int buffSize); static v... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.