use of org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint in project drill by apache.
the class TestBitBitKerberos method successEncryptionChunkMode.
@Test
public void successEncryptionChunkMode(@Injectable WorkerBee bee, @Injectable final WorkEventBus workBus) throws Exception {
newConfig = new DrillConfig(config.withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("kerberos"))).withValue(ExecConstants.BIT_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.BIT_AUTHENTICATION_MECHANISM, ConfigValueFactory.fromAnyRef("kerberos")).withValue(ExecConstants.BIT_ENCRYPTION_SASL_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.BIT_ENCRYPTION_SASL_MAX_WRAPPED_SIZE, ConfigValueFactory.fromAnyRef(100000)).withValue(ExecConstants.USE_LOGIN_PRINCIPAL, ConfigValueFactory.fromAnyRef(true)).withValue(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())), false);
updateTestCluster(1, newConfig);
new NonStrictExpectations() {
{
workBus.getFragmentManagerIfExists((FragmentHandle) any);
result = manager;
workBus.getFragmentManager((FragmentHandle) any);
result = manager;
}
};
DataConnectionConfig config = new DataConnectionConfig(c1.getAllocator(), c1, new DataServerRequestHandler(workBus, bee));
DataServer server = new DataServer(config);
port = server.bind(port, true);
DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
DataConnectionManager connectionManager = new DataConnectionManager(ep, config);
DataTunnel tunnel = new DataTunnel(connectionManager);
AtomicLong max = new AtomicLong(0);
for (int i = 0; i < 40; i++) {
long t1 = System.currentTimeMillis();
tunnel.sendRecordBatch(new TimingOutcome(max), new FragmentWritableBatch(false, QueryId.getDefaultInstance(), 1, 1, 1, 1, getRandomBatch(c1.getAllocator(), 5000)));
System.out.println(System.currentTimeMillis() - t1);
}
System.out.println(String.format("Max time: %d", max.get()));
assertTrue(max.get() > 2700);
Thread.sleep(5000);
}
use of org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint in project drill by apache.
the class TestBitRpc method testConnectionBackpressure.
@Test
public void testConnectionBackpressure(@Injectable WorkerBee bee, @Injectable final WorkEventBus workBus) throws Exception {
DrillConfig config1 = DrillConfig.create();
final BootStrapContext c = new BootStrapContext(config1, ClassPathScanner.fromPrescan(config1));
DrillConfig config2 = DrillConfig.create();
BootStrapContext c2 = new BootStrapContext(config2, ClassPathScanner.fromPrescan(config2));
final FragmentContext fcon = new MockUp<FragmentContext>() {
BufferAllocator getAllocator() {
return c.getAllocator();
}
}.getMockInstance();
final FragmentManager fman = new MockUp<FragmentManager>() {
int v = 0;
@Mock
boolean handle(IncomingDataBatch batch) throws FragmentSetupException, IOException {
try {
v++;
if (v % 10 == 0) {
System.out.println("sleeping.");
Thread.sleep(3000);
}
} catch (InterruptedException e) {
}
RawFragmentBatch rfb = batch.newRawFragmentBatch(c.getAllocator());
rfb.sendOk();
rfb.release();
return true;
}
public FragmentContext getFragmentContext() {
return fcon;
}
}.getMockInstance();
new NonStrictExpectations() {
{
workBus.getFragmentManagerIfExists((FragmentHandle) any);
result = fman;
workBus.getFragmentManager((FragmentHandle) any);
result = fman;
}
};
int port = 1234;
DataConnectionConfig config = new DataConnectionConfig(c.getAllocator(), c, new DataServerRequestHandler(workBus, bee));
DataServer server = new DataServer(config);
port = server.bind(port, true);
DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
DataConnectionManager manager = new DataConnectionManager(ep, config);
DataTunnel tunnel = new DataTunnel(manager);
AtomicLong max = new AtomicLong(0);
for (int i = 0; i < 40; i++) {
long t1 = System.currentTimeMillis();
tunnel.sendRecordBatch(new TimingOutcome(max), new FragmentWritableBatch(false, QueryId.getDefaultInstance(), 1, 1, 1, 1, getRandomBatch(c.getAllocator(), 5000)));
System.out.println(System.currentTimeMillis() - t1);
// System.out.println("sent.");
}
System.out.println(String.format("Max time: %d", max.get()));
assertTrue(max.get() > 2700);
Thread.sleep(5000);
}
use of org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint in project drill by apache.
the class TestCustomTunnel method ensureRoundTripBytes.
@Test
public void ensureRoundTripBytes() throws Exception {
final DrillbitContext context = getDrillbitContext();
final TestCustomMessageHandler handler = new TestCustomMessageHandler(context.getEndpoint(), true);
context.getController().registerCustomHandler(1002, handler, DrillbitEndpoint.PARSER);
final ControlTunnel loopbackTunnel = context.getController().getTunnel(context.getEndpoint());
final CustomTunnel<DrillbitEndpoint, QueryId> tunnel = loopbackTunnel.getCustomTunnel(1002, DrillbitEndpoint.class, QueryId.PARSER);
buf1.retain();
CustomFuture<QueryId> future = tunnel.send(context.getEndpoint(), buf1);
assertEquals(expectedId, future.get());
byte[] actual = new byte[1024];
future.getBuffer().getBytes(0, actual);
future.getBuffer().release();
assertTrue(Arrays.equals(expected, actual));
}
use of org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint in project drill by apache.
the class AffinityCreator method getAffinityMap.
public static <T extends CompleteWork> List<EndpointAffinity> getAffinityMap(List<T> work) {
Stopwatch watch = Stopwatch.createStarted();
long totalBytes = 0;
for (CompleteWork entry : work) {
totalBytes += entry.getTotalBytes();
}
ObjectFloatHashMap<DrillbitEndpoint> affinities = new ObjectFloatHashMap<DrillbitEndpoint>();
for (CompleteWork entry : work) {
for (ObjectLongCursor<DrillbitEndpoint> cursor : entry.getByteMap()) {
long bytes = cursor.value;
float affinity = (float) bytes / (float) totalBytes;
affinities.putOrAdd(cursor.key, affinity, affinity);
}
}
List<EndpointAffinity> affinityList = Lists.newLinkedList();
for (ObjectFloatCursor<DrillbitEndpoint> d : affinities) {
logger.debug("Endpoint {} has affinity {}", d.key.getAddress(), d.value);
affinityList.add(new EndpointAffinity(d.key, d.value));
}
logger.debug("Took {} ms to get operator affinity", watch.elapsed(TimeUnit.MILLISECONDS));
return affinityList;
}
use of org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint in project drill by apache.
the class AssignmentCreator method getMappings.
/**
* Does the work of creating the mappings for this AssignmentCreator
* @return the minor fragment id to work units mapping
*/
private ListMultimap<Integer, T> getMappings() {
Stopwatch watch = Stopwatch.createStarted();
maxWork = (int) Math.ceil(units.size() / ((float) incomingEndpoints.size()));
LinkedList<WorkEndpointListPair<T>> workList = getWorkList();
LinkedList<WorkEndpointListPair<T>> unassignedWorkList;
Map<DrillbitEndpoint, FragIteratorWrapper> endpointIterators = getEndpointIterators();
// Assign upto maxCount per node based on locality.
unassignedWorkList = assign(workList, endpointIterators, false);
// Assign upto minCount per node in a round robin fashion.
assignLeftovers(unassignedWorkList, endpointIterators, true);
// Assign upto maxCount + leftovers per node based on locality.
unassignedWorkList = assign(unassignedWorkList, endpointIterators, true);
// Assign upto maxCount + leftovers per node in a round robin fashion.
assignLeftovers(unassignedWorkList, endpointIterators, false);
if (unassignedWorkList.size() != 0) {
throw new DrillRuntimeException("There are still unassigned work units");
}
logger.debug("Took {} ms to assign {} work units to {} fragments", watch.elapsed(TimeUnit.MILLISECONDS), units.size(), incomingEndpoints.size());
return mappings;
}
Aggregations