Search in sources :

Example 6 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project hive by apache.

the class LlapProtocolServerImpl method getDelegationToken.

@Override
public GetTokenResponseProto getDelegationToken(RpcController controller, GetTokenRequestProto request) throws ServiceException {
    if (secretManager == null) {
        throw new ServiceException("Operation not supported on unsecure cluster");
    }
    UserGroupInformation callingUser = null;
    Token<LlapTokenIdentifier> token = null;
    try {
        callingUser = UserGroupInformation.getCurrentUser();
        // Determine if the user would need to sign fragments.
        boolean isSigningRequired = determineIfSigningIsRequired(callingUser);
        token = secretManager.createLlapToken(request.hasAppId() ? request.getAppId() : null, null, isSigningRequired);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    if (isRestrictedToClusterUser && !clusterUser.equals(callingUser.getShortUserName())) {
        throw new ServiceException("Management protocol ACL is too permissive. The access has been" + " automatically restricted to " + clusterUser + "; " + callingUser.getShortUserName() + " is denied acccess. Please set " + ConfVars.LLAP_VALIDATE_ACLS.varname + " to false," + " or adjust " + ConfVars.LLAP_MANAGEMENT_ACL.varname + " and " + ConfVars.LLAP_MANAGEMENT_ACL_DENY.varname + " to a more restrictive ACL.");
    }
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    try {
        token.write(out);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    ByteString bs = ByteString.copyFrom(out.toByteArray());
    GetTokenResponseProto response = GetTokenResponseProto.newBuilder().setToken(bs).build();
    return response;
}
Also used : LlapTokenIdentifier(org.apache.hadoop.hive.llap.security.LlapTokenIdentifier) ServiceException(com.google.protobuf.ServiceException) GetTokenResponseProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.GetTokenResponseProto) ByteString(com.google.protobuf.ByteString) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 7 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project druid by druid-io.

the class DatasourceInputSplitTest method testSerde.

@Test
public void testSerde() throws Exception {
    Interval interval = Interval.parse("2000/3000");
    DatasourceInputSplit expected = new DatasourceInputSplit(Lists.newArrayList(new WindowedDataSegment(new DataSegment("test", Interval.parse("2000/3000"), "ver", ImmutableMap.<String, Object>of("type", "local", "path", "/tmp/index.zip"), ImmutableList.of("host"), ImmutableList.of("visited_sum", "unique_hosts"), NoneShardSpec.instance(), 9, 12334), interval)), new String[] { "server1", "server2", "server3" });
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    expected.write(out);
    DataInput in = ByteStreams.newDataInput(out.toByteArray());
    DatasourceInputSplit actual = new DatasourceInputSplit();
    actual.readFields(in);
    Assert.assertEquals(expected.getSegments(), actual.getSegments());
    Assert.assertArrayEquals(expected.getLocations(), actual.getLocations());
    Assert.assertEquals(12334, actual.getLength());
}
Also used : DataInput(java.io.DataInput) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) DataSegment(io.druid.timeline.DataSegment) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 8 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.

the class RaptorColumnIdentity method serialize.

@Override
public byte[] serialize() {
    ByteArrayDataOutput output = newDataOutput(SERIALIZED_SIZE);
    output.write(CURRENT_VERSION);
    output.writeLong(columnId);
    return output.toByteArray();
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput)

Example 9 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.

the class WrappedRange method toBytes.

@JsonValue
public byte[] toBytes() throws IOException {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    range.write(out);
    return out.toByteArray();
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) JsonValue(com.fasterxml.jackson.annotation.JsonValue)

Example 10 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project presto by prestodb.

the class RaptorTableIdentity method serialize.

@Override
public byte[] serialize() {
    ByteArrayDataOutput output = newDataOutput(SERIALIZED_SIZE);
    output.write(CURRENT_VERSION);
    output.writeLong(tableId);
    return output.toByteArray();
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput)

Aggregations

ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)20 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)2 IOException (java.io.IOException)2 Test (org.testng.annotations.Test)2 Split (co.cask.cdap.api.data.batch.Split)1 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)1 RaptorColumnIdentity (com.facebook.presto.raptor.RaptorColumnIdentity)1 RaptorTableIdentity (com.facebook.presto.raptor.RaptorTableIdentity)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ColumnIdentity (com.facebook.presto.spi.ColumnIdentity)1 TableIdentity (com.facebook.presto.spi.TableIdentity)1 JsonValue (com.fasterxml.jackson.annotation.JsonValue)1 Supplier (com.google.common.base.Supplier)1 ByteString (com.google.protobuf.ByteString)1 ServiceException (com.google.protobuf.ServiceException)1 InputRow (io.druid.data.input.InputRow)1 MapBasedInputRow (io.druid.data.input.MapBasedInputRow)1 ParseException (io.druid.java.util.common.parsers.ParseException)1 Aggregator (io.druid.query.aggregation.Aggregator)1 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)1