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()));
}
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;
}
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());
}
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);
}
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());
}
Aggregations