use of com.google.common.io.ByteArrayDataInput in project cdap by caskdata.
the class AbstractBatchReadableInputFormat method getSplits.
@Override
public List<InputSplit> getSplits(final JobContext context) throws IOException, InterruptedException {
// Decode splits from Configuration
String splitsConf = context.getConfiguration().get(SPLITS);
if (splitsConf == null) {
throw new IOException("No input splits available from job configuration.");
}
ByteArrayDataInput dataInput = ByteStreams.newDataInput(Bytes.toBytesBinary(splitsConf));
int size = dataInput.readInt();
List<InputSplit> splits = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
DataSetInputSplit inputSplit = new DataSetInputSplit();
inputSplit.readFields(dataInput);
splits.add(inputSplit);
}
return splits;
}
use of com.google.common.io.ByteArrayDataInput in project SpaciousLib by anhcraft.
the class BungeeManager method onPluginMessageReceived.
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(CHANNEL)) {
return;
}
ByteArrayDataInput i = ByteStreams.newDataInput(message);
String sc = i.readUTF();
boolean b = false;
for (BungeeResponse br : queue) {
if (sc.equals("IP") && br instanceof BungeePlayerIPResponse) {
((BungeePlayerIPResponse) br).result(i.readUTF(), i.readInt());
b = true;
}
if (sc.equals("PlayerCount") && br instanceof BungeePlayerAmountResponse) {
((BungeePlayerAmountResponse) br).result(i.readUTF(), i.readInt());
b = true;
}
if (sc.equals("PlayerList") && br instanceof BungeePlayerListResponse) {
((BungeePlayerListResponse) br).result(i.readUTF(), new ArrayList<>(Arrays.asList(i.readUTF().split(", "))));
b = true;
}
if (sc.equals("GetServers") && br instanceof BungeeServerListResponse) {
((BungeeServerListResponse) br).result(new ArrayList<>(Arrays.asList(i.readUTF().split(", "))));
b = true;
}
if (sc.equals("GetServer") && br instanceof BungeeServerNameResponse) {
((BungeeServerNameResponse) br).result(i.readUTF());
b = true;
}
if (sc.equals("UUID") && br instanceof BungeePlayerUUIDResponse) {
((BungeePlayerUUIDResponse) br).result(UUID.fromString(i.readUTF()));
b = true;
}
if (sc.equals("UUIDOther") && br instanceof BungeeOtherPlayerUUIDResponse) {
((BungeeOtherPlayerUUIDResponse) br).result(i.readUTF(), UUID.fromString(i.readUTF()));
b = true;
}
if (sc.equals("ServerIP") && br instanceof BungeeServerIPResponse) {
((BungeeServerIPResponse) br).result(i.readUTF(), i.readUTF(), i.readUnsignedShort());
b = true;
}
if (b) {
break;
}
}
if (b) {
queue.remove(0);
} else {
byte[] bytedata = new byte[i.readShort()];
i.readFully(bytedata);
DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytedata));
BungeeForwardEvent ev = new BungeeForwardEvent(sc, data);
Bukkit.getServer().getPluginManager().callEvent(ev);
}
}
use of com.google.common.io.ByteArrayDataInput in project Network-depr by Mas281.
the class BungeeListener method onPluginMessageReceived.
@Override
public void onPluginMessageReceived(String channel, Player unused, byte[] data) {
ByteArrayDataInput in = ByteStreams.newDataInput(data);
if (channel.equals("BungeeCord")) {
switch(in.readUTF()) {
case "GetServer":
{
String serverName = in.readUTF();
log("Received server name: %s ", serverName);
module.setServerName(serverName);
if (module instanceof RedisNetwork) {
((RedisNetwork) module).resetQueue();
}
break;
}
case "GetServers":
{
Set<String> servers = Sets.newHashSet(in.readUTF().split(", "));
module.setServers(Collections.unmodifiableSet(servers));
break;
}
}
} else if (channel.equals("ServerUpdates")) {
switch(in.readUTF()) {
case "ProxyLeave":
{
String player = in.readUTF();
module.removeTrackingData(player);
}
}
}
}
Aggregations