Search in sources :

Example 31 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project cdap by caskdata.

the class AbstractBatchReadableInputFormat method setDatasetSplits.

/**
   * Sets dataset and splits information into the given {@link Configuration}.
   *
   * @param hConf            configuration to modify
   * @param datasetNamespace namespace of the dataset
   * @param datasetName      name of the dataset
   * @param datasetArguments arguments for the dataset
   * @param splits           list of splits on the dataset
   * @throws IOException
   */
public static void setDatasetSplits(Configuration hConf, @Nullable String datasetNamespace, String datasetName, Map<String, String> datasetArguments, List<Split> splits) throws IOException {
    if (datasetNamespace != null) {
        hConf.set(DATASET_NAMESPACE, datasetNamespace);
    }
    hConf.set(DATASET_NAME, datasetName);
    hConf.set(DATASET_ARGS, GSON.toJson(datasetArguments, DATASET_ARGS_TYPE));
    // Encode the list of splits with size followed by that many of DataSetInputSplit objects.
    ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
    dataOutput.writeInt(splits.size());
    for (Split split : splits) {
        new DataSetInputSplit(split).write(dataOutput);
    }
    hConf.set(SPLITS, Bytes.toStringBinary(dataOutput.toByteArray()));
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) InputSplit(org.apache.hadoop.mapreduce.InputSplit) Split(co.cask.cdap.api.data.batch.Split)

Example 32 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 access. 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 33 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.

the class BungeeManager method connect.

/**
 * Sends a connect request for the given player who is in another server
 * @param player the player
 * @param server the server which you want the player connects to
 */
public static void connect(String player, String server) {
    if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
        return;
    }
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("ConnectOther");
    out.writeUTF(player);
    out.writeUTF(server);
    Bukkit.getServer().getOnlinePlayers().iterator().next().sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput)

Example 34 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.

the class BungeeManager method getUUIDOther.

/**
 * Gets the UUID of a player who is in another server
 * @param player the player
 * @param response BungeeOtherPlayerUUIDResponse object
 */
public static void getUUIDOther(String player, BungeeOtherPlayerUUIDResponse response) {
    if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
        return;
    }
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("UUIDOther");
    out.writeUTF(player);
    Bukkit.getServer().getOnlinePlayers().iterator().next().sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
    queue.add(response);
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput)

Example 35 with ByteArrayDataOutput

use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.

the class BungeeManager method connect.

/**
 * Sends a connect request for the given player<br>
 * If success, that player will be connected to the given server automatically
 * @param player the player
 * @param server the server which you want the player connects to
 */
public static void connect(Player player, String server) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("Connect");
    out.writeUTF(server);
    player.sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
}
Also used : ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput)

Aggregations

ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)39 IOException (java.io.IOException)3 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)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