use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project hadoop by apache.
the class PBImageXmlWriter method dumpXattrs.
private void dumpXattrs(INodeSection.XAttrFeatureProto xattrs) {
out.print("<" + INODE_SECTION_XATTRS + ">");
for (INodeSection.XAttrCompactProto xattr : xattrs.getXAttrsList()) {
out.print("<" + INODE_SECTION_XATTR + ">");
int encodedName = xattr.getName();
int ns = (XATTR_NAMESPACE_MASK & (encodedName >> XATTR_NAMESPACE_OFFSET)) | ((XATTR_NAMESPACE_EXT_MASK & (encodedName >> XATTR_NAMESPACE_EXT_OFFSET)) << 2);
o(INODE_SECTION_NS, XAttrProtos.XAttrProto.XAttrNamespaceProto.valueOf(ns).toString());
o(SECTION_NAME, stringTable[XATTR_NAME_MASK & (encodedName >> XATTR_NAME_OFFSET)]);
ByteString val = xattr.getValue();
if (val.isValidUtf8()) {
o(INODE_SECTION_VAL, val.toStringUtf8());
} else {
o(INODE_SECTION_VAL_HEX, Hex.encodeHexString(val.toByteArray()));
}
out.print("</" + INODE_SECTION_XATTR + ">");
}
out.print("</" + INODE_SECTION_XATTRS + ">");
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project hadoop by apache.
the class BlockListAsLongs method getBlocksBuffers.
/**
* List of ByteStrings that encode this block report
*
* @return ByteStrings
*/
public List<ByteString> getBlocksBuffers() {
final ByteString blocksBuf = getBlocksBuffer();
final List<ByteString> buffers;
final int size = blocksBuf.size();
if (size <= CHUNK_SIZE) {
buffers = Collections.singletonList(blocksBuf);
} else {
buffers = new ArrayList<ByteString>();
for (int pos = 0; pos < size; pos += CHUNK_SIZE) {
// this doesn't actually copy the data
buffers.add(blocksBuf.substring(pos, Math.min(pos + CHUNK_SIZE, size)));
}
}
return buffers;
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project hadoop by apache.
the class TestBlockListAsLongs method checkReport.
private BlockListAsLongs checkReport(Replica... replicas) {
Map<Long, Replica> expectedReplicas = new HashMap<>();
for (Replica replica : replicas) {
expectedReplicas.put(replica.getBlockId(), replica);
}
expectedReplicas = Collections.unmodifiableMap(expectedReplicas);
// encode the blocks and extract the buffers
BlockListAsLongs blocks = BlockListAsLongs.encode(expectedReplicas.values());
List<ByteString> buffers = blocks.getBlocksBuffers();
// convert to old-style list of longs
List<Long> longs = new ArrayList<Long>();
for (long value : blocks.getBlockListAsLongs()) {
longs.add(value);
}
// decode the buffers and verify its contents
BlockListAsLongs decodedBlocks = BlockListAsLongs.decodeBuffers(expectedReplicas.size(), buffers);
checkReplicas(expectedReplicas, decodedBlocks);
// decode the long and verify its contents
BlockListAsLongs decodedList = BlockListAsLongs.decodeLongs(longs);
checkReplicas(expectedReplicas, decodedList);
return blocks;
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project intellij-community by JetBrains.
the class ExternalJavacMessageHandler method handleMessage.
public boolean handleMessage(MessageLite message) {
try {
final JavacRemoteProto.Message msg = (JavacRemoteProto.Message) message;
final JavacRemoteProto.Message.Type messageType = msg.getMessageType();
if (messageType == JavacRemoteProto.Message.Type.RESPONSE) {
final JavacRemoteProto.Message.Response response = msg.getResponse();
final JavacRemoteProto.Message.Response.Type responseType = response.getResponseType();
if (responseType == JavacRemoteProto.Message.Response.Type.BUILD_MESSAGE) {
final JavacRemoteProto.Message.Response.CompileMessage compileMessage = response.getCompileMessage();
final JavacRemoteProto.Message.Response.CompileMessage.Kind messageKind = compileMessage.getKind();
if (messageKind == JavacRemoteProto.Message.Response.CompileMessage.Kind.STD_OUT) {
if (compileMessage.hasText()) {
myDiagnosticSink.outputLineAvailable(compileMessage.getText());
}
} else {
final String sourceUri = compileMessage.hasSourceUri() ? compileMessage.getSourceUri() : null;
final JavaFileObject srcFileObject = sourceUri != null ? new DummyJavaFileObject(URI.create(sourceUri)) : null;
myDiagnosticSink.report(new DummyDiagnostic(convertKind(messageKind), srcFileObject, compileMessage));
}
return false;
}
if (responseType == JavacRemoteProto.Message.Response.Type.OUTPUT_OBJECT) {
final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject();
final JavacRemoteProto.Message.Response.OutputObject.Kind kind = outputObject.getKind();
final String outputRoot = outputObject.hasOutputRoot() ? outputObject.getOutputRoot() : null;
final File outputRootFile = outputRoot != null ? new File(outputRoot) : null;
final BinaryContent fileObjectContent;
final ByteString content = outputObject.hasContent() ? outputObject.getContent() : null;
if (content != null) {
final byte[] bytes = content.toByteArray();
fileObjectContent = new BinaryContent(bytes, 0, bytes.length);
} else {
fileObjectContent = null;
}
final String sourceUri = outputObject.hasSourceUri() ? outputObject.getSourceUri() : null;
final URI srcUri = sourceUri != null ? URI.create(sourceUri) : null;
final OutputFileObject fileObject = new OutputFileObject(null, outputRootFile, outputObject.hasRelativePath() ? outputObject.getRelativePath() : null, new File(outputObject.getFilePath()), convertKind(kind), outputObject.hasClassName() ? outputObject.getClassName() : null, srcUri, myEncodingName, fileObjectContent);
myOutputSink.save(fileObject);
return false;
}
if (responseType == JavacRemoteProto.Message.Response.Type.SRC_FILE_LOADED) {
final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject();
final File file = new File(outputObject.getFilePath());
myDiagnosticSink.javaFileLoaded(file);
return false;
}
if (responseType == JavacRemoteProto.Message.Response.Type.CLASS_DATA) {
final JavacRemoteProto.Message.Response.ClassData data = response.getClassData();
final String className = data.getClassName();
final Collection<String> imports = data.getImportStatementList();
final Collection<String> staticImports = data.getStaticImportList();
myDiagnosticSink.registerImports(className, imports, staticImports);
return false;
}
if (responseType == JavacRemoteProto.Message.Response.Type.CUSTOM_OUTPUT_OBJECT) {
final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject();
final String pluginId = outputObject.getFilePath();
final String name = outputObject.getClassName();
final byte[] content = outputObject.hasContent() ? outputObject.getContent().toByteArray() : new byte[0];
myDiagnosticSink.customOutputData(pluginId, name, content);
return false;
}
if (responseType == JavacRemoteProto.Message.Response.Type.BUILD_COMPLETED) {
if (response.hasCompletionStatus()) {
myTerminatedSuccessfully = response.getCompletionStatus();
}
return true;
}
throw new Exception("Unsupported response type: " + responseType.name());
}
if (messageType == JavacRemoteProto.Message.Type.FAILURE) {
final JavacRemoteProto.Message.Failure failure = msg.getFailure();
final StringBuilder buf = new StringBuilder();
if (failure.hasDescription()) {
buf.append(failure.getDescription());
}
if (failure.hasStacktrace()) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(failure.getStacktrace());
}
myDiagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, buf.toString()));
return true;
}
throw new Exception("Unsupported message type: " + messageType.name());
} catch (Throwable e) {
myDiagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, e.getMessage()));
return true;
}
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project heron by twitter.
the class BoltInstance method handleDataTuple.
private void handleDataTuple(HeronTuples.HeronDataTuple dataTuple, TopologyAPI.StreamId stream) {
long startTime = System.nanoTime();
List<Object> values = new ArrayList<>();
for (ByteString b : dataTuple.getValuesList()) {
values.add(serializer.deserialize(b.toByteArray()));
}
// Decode the tuple
TupleImpl t = new TupleImpl(helper.getTopologyContext(), stream, dataTuple.getKey(), dataTuple.getRootsList(), values);
long deserializedTime = System.nanoTime();
// Delegate to the use defined bolt
bolt.execute(t);
long executeLatency = System.nanoTime() - deserializedTime;
// Invoke user-defined execute task hook
helper.getTopologyContext().invokeHookBoltExecute(t, executeLatency);
boltMetrics.deserializeDataTuple(stream.getId(), stream.getComponentName(), deserializedTime - startTime);
// Update metrics
boltMetrics.executeTuple(stream.getId(), stream.getComponentName(), executeLatency);
}
Aggregations