├── .gitignore ├── LICENSE ├── README.md ├── atomlayer ├── baggagecontext-impl │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ └── impl │ │ │ ├── AtomContext.java │ │ │ ├── AtomContextProvider.java │ │ │ └── AtomContextProviderFactory.java │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── impl │ │ └── TestAtomContext.java ├── core │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ └── atomlayer │ │ │ ├── AtomLayerException.java │ │ │ ├── AtomLayerOverflow.java │ │ │ ├── AtomLayerSerialization.java │ │ │ ├── ByteBuffers.java │ │ │ ├── Lexicographic.java │ │ │ ├── MergeIterator.java │ │ │ ├── MergeTwoIterator.java │ │ │ ├── ProtobufVarint.java │ │ │ ├── SignedLexVarint.java │ │ │ ├── StringUtils.java │ │ │ ├── TypeUtils.java │ │ │ ├── UnsignedByteBuffer.java │ │ │ ├── UnsignedLexVarint.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── atomlayer │ │ ├── TestByteBuffers.java │ │ ├── TestMerge.java │ │ ├── TestMergeIterator.java │ │ ├── TestMergeTwoIterator.java │ │ ├── TestOverflowMarker.java │ │ ├── TestProtobufVarint.java │ │ ├── TestSerialization.java │ │ ├── TestSerializedSize.java │ │ ├── TestUnsignedByteBuffer.java │ │ ├── TestXSignedVarint32.java │ │ ├── TestXSignedVarint64.java │ │ ├── TestXUnsignedVarint32.java │ │ └── TestXUnsignedVarint64.java └── pom.xml ├── baggagecontext ├── api │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ ├── BaggageContext.java │ │ ├── BaggageProvider.java │ │ ├── BaggageProviderFactory.java │ │ └── package-info.java ├── pom.xml ├── staticapi │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ ├── Baggage.java │ │ │ ├── BaggageProviderProxy.java │ │ │ ├── DefaultBaggageProvider.java │ │ │ └── impl │ │ │ ├── NoOpBaggageContextProvider.java │ │ │ ├── NoOpBaggageContextProviderFactory.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ ├── TestStaticAPI.java │ │ └── impl │ │ └── TestNoOpBaggageContextProvider.java └── transitlayer │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── brown │ │ └── tracingplane │ │ ├── ActiveBaggage.java │ │ ├── DefaultTransitLayer.java │ │ ├── TransitLayer.java │ │ ├── TransitLayerFactory.java │ │ └── impl │ │ ├── NoOpTransitLayer.java │ │ ├── NoOpTransitLayerFactory.java │ │ ├── ThreadLocalTransitLayer.java │ │ └── ThreadLocalTransitLayerFactory.java │ └── test │ └── java │ └── brown │ └── tracingplane │ ├── TestActiveBaggage.java │ └── impl │ ├── TestNoOpTransitLayer.java │ └── TestThreadLocalTransitLayer.java ├── baggageprotocol ├── baggagecontext-impl │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── impl │ │ ├── NestedBaggageContext.java │ │ ├── NestedBaggageContextProvider.java │ │ └── NestedBaggageContextProviderFactory.java ├── core │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ └── baggageprotocol │ │ │ ├── AtomPrefixTypes.java │ │ │ ├── AtomPrefixes.java │ │ │ ├── BagKey.java │ │ │ ├── BagOptions.java │ │ │ ├── BaggageLayerException.java │ │ │ ├── BaggageProtocol.java │ │ │ ├── BaggageReader.java │ │ │ ├── BaggageWriter.java │ │ │ ├── ElementReader.java │ │ │ ├── ElementWriter.java │ │ │ ├── HeaderSerialization.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── baggageprotocol │ │ ├── BaggageTestCase.java │ │ ├── TestAtomPrefixComparison.java │ │ ├── TestAtomPrefixTypes.java │ │ ├── TestAtomPrefixes.java │ │ ├── TestBagKey.java │ │ ├── TestBaggage01_OneDataElement.java │ │ ├── TestBaggage02_EmptyBaggage.java │ │ ├── TestBaggage03_MultipleDataElements.java │ │ ├── TestBaggage04_OneChild.java │ │ ├── TestBaggage05_NestedChildren.java │ │ ├── TestBaggage06_Siblings.java │ │ ├── TestBaggage07_EmptyBags.java │ │ ├── TestHeaderSerialization.java │ │ ├── TestOverflowMarker.java │ │ ├── TestOverflowMarker2.java │ │ ├── TestOverflowMarkerMerge.java │ │ ├── TestReaderWriter.java │ │ ├── TestReassembleUnprocessed.java │ │ └── TestSort.java └── pom.xml ├── bdl ├── baggagecontext-impl │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── brown │ │ │ │ └── tracingplane │ │ │ │ ├── BaggageListener.java │ │ │ │ └── impl │ │ │ │ ├── BDLContext.java │ │ │ │ ├── BDLContextProvider.java │ │ │ │ ├── BDLContextProviderFactory.java │ │ │ │ ├── BDLContextUtils.java │ │ │ │ └── BaggageHandlerRegistry.java │ │ └── resources │ │ │ └── reference.conf │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── impl │ │ ├── TestBBUtils.java │ │ ├── TestBaggageListener.java │ │ └── TestBaggageRegistry.java ├── compiler │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── brown │ │ │ │ └── tracingplane │ │ │ │ └── bdl │ │ │ │ └── compiler │ │ │ │ ├── BBC.java │ │ │ │ ├── CompileException.java │ │ │ │ ├── Compiler.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── JavaCompilerUtils.java │ │ │ │ └── Linker.java │ │ ├── resources │ │ │ ├── example.bb │ │ │ └── log4j-bbcompiler.properties │ │ └── scala │ │ │ └── brown │ │ │ └── tracingplane │ │ │ └── bdl │ │ │ └── compiler │ │ │ ├── Ast.scala │ │ │ ├── Declarations.scala │ │ │ ├── JavaCompiler.scala │ │ │ └── Parser.scala │ │ └── test │ │ ├── java │ │ └── brown │ │ │ └── tracingplane │ │ │ └── bdl │ │ │ └── compiler │ │ │ └── TestLinker.java │ │ └── scala │ │ └── brown │ │ └── tracingplane │ │ └── bdl │ │ └── compiler │ │ └── TestDeclarations.scala ├── core │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ └── bdl │ │ │ ├── BDLUtils.java │ │ │ ├── Bag.java │ │ │ ├── BaggageHandler.java │ │ │ ├── Brancher.java │ │ │ ├── Branchers.java │ │ │ ├── Cast.java │ │ │ ├── CounterImpl.java │ │ │ ├── Joiner.java │ │ │ ├── Joiners.java │ │ │ ├── Parser.java │ │ │ ├── Parsers.java │ │ │ ├── ReaderHelpers.java │ │ │ ├── Serializer.java │ │ │ ├── Serializers.java │ │ │ ├── SpecialTypes.java │ │ │ ├── Struct.java │ │ │ ├── StructHelpers.java │ │ │ ├── WriterHelpers.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── brown │ │ └── tracingplane │ │ └── bdl │ │ ├── TestCounterImpl.java │ │ └── TestStructHelpers.java ├── examples │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── baggage │ │ │ │ ├── example.bb │ │ │ │ └── xtrace.bb │ │ └── test │ │ │ └── java │ │ │ └── brown │ │ │ └── tracingplane │ │ │ ├── bdl │ │ │ ├── TestBBUtils.java │ │ │ └── examples │ │ │ │ ├── Example.java │ │ │ │ └── TestXTraceBaggage.java │ │ │ └── impl │ │ │ └── TestExampleBag.java │ └── target │ │ └── generated-sources │ │ └── brown │ │ ├── tracingplane │ │ └── bdl │ │ │ └── examples │ │ │ ├── ExampleBag.java │ │ │ ├── FonsecaBag.java │ │ │ ├── SimpleBag.java │ │ │ ├── SimpleBag2.java │ │ │ ├── SimpleStruct1.java │ │ │ └── SimpleStruct2.java │ │ └── xtrace │ │ └── XTraceBaggage.java └── pom.xml ├── dist ├── github │ └── pom.xml ├── pom.xml └── tracingplane │ ├── pom.xml │ └── src │ ├── main │ └── resources │ │ └── reference.conf │ └── test │ └── java │ └── brown │ └── tracingplane │ └── TestConfiguration.java ├── doc ├── allclasses-frame.html ├── allclasses-noframe.html ├── atom-layer.md ├── baggage-buffers-tutorial.md ├── baggage-layer.md ├── brown │ ├── tracingplane │ │ ├── ActiveBaggage.html │ │ ├── Baggage.html │ │ ├── BaggageContext.html │ │ ├── BaggageListener.BranchListener.html │ │ ├── BaggageListener.JoinListener.html │ │ ├── BaggageListener.html │ │ ├── BaggageProvider.html │ │ ├── BaggageProviderFactory.html │ │ ├── DefaultBaggageProvider.html │ │ ├── DefaultTransitLayer.html │ │ ├── TestActiveBaggage.html │ │ ├── TestStaticAPI.html │ │ ├── TransitLayer.html │ │ ├── TransitLayerFactory.html │ │ ├── atomlayer │ │ │ ├── AtomLayerException.html │ │ │ ├── AtomLayerOverflow.html │ │ │ ├── AtomLayerSerialization.html │ │ │ ├── ByteBuffers.html │ │ │ ├── Lexicographic.html │ │ │ ├── MergeIterator.html │ │ │ ├── MergeTwoIterator.html │ │ │ ├── ProtobufVarint.EndOfStreamException.html │ │ │ ├── ProtobufVarint.MalformedVarintException.html │ │ │ ├── ProtobufVarint.html │ │ │ ├── SignedLexVarint.html │ │ │ ├── StringUtils.html │ │ │ ├── TestByteBuffers.html │ │ │ ├── TestMerge.html │ │ │ ├── TestMergeIterator.html │ │ │ ├── TestMergeTwoIterator.html │ │ │ ├── TestOverflowMarker.html │ │ │ ├── TestProtobufVarint.html │ │ │ ├── TestSerialization.html │ │ │ ├── TestSerializedSize.html │ │ │ ├── TestUnsignedByteBuffer.html │ │ │ ├── TestXSignedVarint32.html │ │ │ ├── TestXSignedVarint64.html │ │ │ ├── TestXUnsignedVarint32.html │ │ │ ├── TestXUnsignedVarint64.html │ │ │ ├── TypeUtils.html │ │ │ ├── UnsignedByteBuffer.html │ │ │ ├── UnsignedLexVarint.html │ │ │ ├── class-use │ │ │ │ ├── AtomLayerException.html │ │ │ │ ├── AtomLayerOverflow.html │ │ │ │ ├── AtomLayerSerialization.html │ │ │ │ ├── ByteBuffers.html │ │ │ │ ├── Lexicographic.html │ │ │ │ ├── MergeIterator.html │ │ │ │ ├── MergeTwoIterator.html │ │ │ │ ├── ProtobufVarint.EndOfStreamException.html │ │ │ │ ├── ProtobufVarint.MalformedVarintException.html │ │ │ │ ├── ProtobufVarint.html │ │ │ │ ├── SignedLexVarint.html │ │ │ │ ├── StringUtils.html │ │ │ │ ├── TestByteBuffers.html │ │ │ │ ├── TestMerge.html │ │ │ │ ├── TestMergeIterator.html │ │ │ │ ├── TestMergeTwoIterator.html │ │ │ │ ├── TestOverflowMarker.html │ │ │ │ ├── TestProtobufVarint.html │ │ │ │ ├── TestSerialization.html │ │ │ │ ├── TestSerializedSize.html │ │ │ │ ├── TestUnsignedByteBuffer.html │ │ │ │ ├── TestXSignedVarint32.html │ │ │ │ ├── TestXSignedVarint64.html │ │ │ │ ├── TestXUnsignedVarint32.html │ │ │ │ ├── TestXUnsignedVarint64.html │ │ │ │ ├── TypeUtils.html │ │ │ │ ├── UnsignedByteBuffer.html │ │ │ │ └── UnsignedLexVarint.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── baggageprotocol │ │ │ ├── AtomPrefixTypes.AtomType.html │ │ │ ├── AtomPrefixTypes.BagOptionsInPrefix.html │ │ │ ├── AtomPrefixTypes.HeaderType.html │ │ │ ├── AtomPrefixTypes.Level.html │ │ │ ├── AtomPrefixTypes.html │ │ │ ├── AtomPrefixes.AtomPrefix.html │ │ │ ├── AtomPrefixes.DataPrefix.html │ │ │ ├── AtomPrefixes.HeaderPrefix.html │ │ │ ├── AtomPrefixes.IndexedHeaderPrefix.html │ │ │ ├── AtomPrefixes.KeyedHeaderPrefix.html │ │ │ ├── AtomPrefixes.UnsupportedPrefix.html │ │ │ ├── AtomPrefixes.html │ │ │ ├── BagKey.Indexed.html │ │ │ ├── BagKey.Keyed.html │ │ │ ├── BagKey.html │ │ │ ├── BagOptions.MergeBehavior.html │ │ │ ├── BagOptions.html │ │ │ ├── BaggageLayerException.BaggageLayerRuntimeException.html │ │ │ ├── BaggageLayerException.html │ │ │ ├── BaggageProtocol.html │ │ │ ├── BaggageReader.html │ │ │ ├── BaggageTestCase.html │ │ │ ├── BaggageWriter.html │ │ │ ├── ElementReader.html │ │ │ ├── ElementWriter.html │ │ │ ├── HeaderSerialization.html │ │ │ ├── TestAtomPrefixComparison.html │ │ │ ├── TestAtomPrefixTypes.html │ │ │ ├── TestAtomPrefixes.html │ │ │ ├── TestBagKey.html │ │ │ ├── TestBaggage01_OneDataElement.html │ │ │ ├── TestBaggage02_EmptyBaggage.html │ │ │ ├── TestBaggage03_MultipleDataElements.html │ │ │ ├── TestBaggage04_OneChild.html │ │ │ ├── TestBaggage05_NestedChildren.html │ │ │ ├── TestBaggage06_Siblings.html │ │ │ ├── TestBaggage07_EmptyBags.html │ │ │ ├── TestHeaderSerialization.html │ │ │ ├── TestOverflowMarker.html │ │ │ ├── TestOverflowMarker2.html │ │ │ ├── TestOverflowMarkerMerge.html │ │ │ ├── TestReaderWriter.html │ │ │ ├── TestReassembleUnprocessed.html │ │ │ ├── TestSort.html │ │ │ ├── class-use │ │ │ │ ├── AtomPrefixTypes.AtomType.html │ │ │ │ ├── AtomPrefixTypes.BagOptionsInPrefix.html │ │ │ │ ├── AtomPrefixTypes.HeaderType.html │ │ │ │ ├── AtomPrefixTypes.Level.html │ │ │ │ ├── AtomPrefixTypes.html │ │ │ │ ├── AtomPrefixes.AtomPrefix.html │ │ │ │ ├── AtomPrefixes.DataPrefix.html │ │ │ │ ├── AtomPrefixes.HeaderPrefix.html │ │ │ │ ├── AtomPrefixes.IndexedHeaderPrefix.html │ │ │ │ ├── AtomPrefixes.KeyedHeaderPrefix.html │ │ │ │ ├── AtomPrefixes.UnsupportedPrefix.html │ │ │ │ ├── AtomPrefixes.html │ │ │ │ ├── BagKey.Indexed.html │ │ │ │ ├── BagKey.Keyed.html │ │ │ │ ├── BagKey.html │ │ │ │ ├── BagOptions.MergeBehavior.html │ │ │ │ ├── BagOptions.html │ │ │ │ ├── BaggageLayerException.BaggageLayerRuntimeException.html │ │ │ │ ├── BaggageLayerException.html │ │ │ │ ├── BaggageProtocol.html │ │ │ │ ├── BaggageReader.html │ │ │ │ ├── BaggageTestCase.html │ │ │ │ ├── BaggageWriter.html │ │ │ │ ├── ElementReader.html │ │ │ │ ├── ElementWriter.html │ │ │ │ ├── HeaderSerialization.html │ │ │ │ ├── TestAtomPrefixComparison.html │ │ │ │ ├── TestAtomPrefixTypes.html │ │ │ │ ├── TestAtomPrefixes.html │ │ │ │ ├── TestBagKey.html │ │ │ │ ├── TestBaggage01_OneDataElement.html │ │ │ │ ├── TestBaggage02_EmptyBaggage.html │ │ │ │ ├── TestBaggage03_MultipleDataElements.html │ │ │ │ ├── TestBaggage04_OneChild.html │ │ │ │ ├── TestBaggage05_NestedChildren.html │ │ │ │ ├── TestBaggage06_Siblings.html │ │ │ │ ├── TestBaggage07_EmptyBags.html │ │ │ │ ├── TestHeaderSerialization.html │ │ │ │ ├── TestOverflowMarker.html │ │ │ │ ├── TestOverflowMarker2.html │ │ │ │ ├── TestOverflowMarkerMerge.html │ │ │ │ ├── TestReaderWriter.html │ │ │ │ ├── TestReassembleUnprocessed.html │ │ │ │ └── TestSort.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── bdl │ │ │ ├── BDLUtils.html │ │ │ ├── Bag.html │ │ │ ├── BaggageHandler.html │ │ │ ├── Brancher.html │ │ │ ├── Branchers.html │ │ │ ├── Cast.html │ │ │ ├── CounterImpl.Handler.html │ │ │ ├── CounterImpl.html │ │ │ ├── Joiner.html │ │ │ ├── Joiners.html │ │ │ ├── Parser.ElementParser.html │ │ │ ├── Parser.html │ │ │ ├── Parsers.html │ │ │ ├── ReaderHelpers.html │ │ │ ├── Serializer.ElementSerializer.html │ │ │ ├── Serializer.html │ │ │ ├── Serializers.html │ │ │ ├── SpecialTypes.Counter.html │ │ │ ├── SpecialTypes.html │ │ │ ├── Struct.StructHandler.html │ │ │ ├── Struct.StructReader.html │ │ │ ├── Struct.StructSizer.html │ │ │ ├── Struct.StructWriter.html │ │ │ ├── Struct.html │ │ │ ├── StructHelpers.html │ │ │ ├── TestBBUtils.html │ │ │ ├── TestCounterImpl.html │ │ │ ├── TestStructHelpers.html │ │ │ ├── WriterHelpers.html │ │ │ ├── class-use │ │ │ │ ├── BDLUtils.html │ │ │ │ ├── Bag.html │ │ │ │ ├── BaggageHandler.html │ │ │ │ ├── Brancher.html │ │ │ │ ├── Branchers.html │ │ │ │ ├── Cast.html │ │ │ │ ├── CounterImpl.Handler.html │ │ │ │ ├── CounterImpl.html │ │ │ │ ├── Joiner.html │ │ │ │ ├── Joiners.html │ │ │ │ ├── Parser.ElementParser.html │ │ │ │ ├── Parser.html │ │ │ │ ├── Parsers.html │ │ │ │ ├── ReaderHelpers.html │ │ │ │ ├── Serializer.ElementSerializer.html │ │ │ │ ├── Serializer.html │ │ │ │ ├── Serializers.html │ │ │ │ ├── SpecialTypes.Counter.html │ │ │ │ ├── SpecialTypes.html │ │ │ │ ├── Struct.StructHandler.html │ │ │ │ ├── Struct.StructReader.html │ │ │ │ ├── Struct.StructSizer.html │ │ │ │ ├── Struct.StructWriter.html │ │ │ │ ├── Struct.html │ │ │ │ ├── StructHelpers.html │ │ │ │ ├── TestBBUtils.html │ │ │ │ ├── TestCounterImpl.html │ │ │ │ ├── TestStructHelpers.html │ │ │ │ └── WriterHelpers.html │ │ │ ├── compiler │ │ │ │ ├── BBC.Settings.html │ │ │ │ ├── BBC.html │ │ │ │ ├── CompileException.html │ │ │ │ ├── Compiler.html │ │ │ │ ├── FileUtils.html │ │ │ │ ├── JavaCompilerUtils.html │ │ │ │ ├── Linker.html │ │ │ │ ├── TestLinker.html │ │ │ │ ├── class-use │ │ │ │ │ ├── BBC.Settings.html │ │ │ │ │ ├── BBC.html │ │ │ │ │ ├── CompileException.html │ │ │ │ │ ├── Compiler.html │ │ │ │ │ ├── FileUtils.html │ │ │ │ │ ├── JavaCompilerUtils.html │ │ │ │ │ ├── Linker.html │ │ │ │ │ └── TestLinker.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── examples │ │ │ │ ├── Example.html │ │ │ │ ├── ExampleBag.Handler.html │ │ │ │ ├── ExampleBag.html │ │ │ │ ├── SimpleBag.Handler.html │ │ │ │ ├── SimpleBag.html │ │ │ │ ├── SimpleBag2.Handler.html │ │ │ │ ├── SimpleBag2.html │ │ │ │ ├── SimpleStruct1.Handler.html │ │ │ │ ├── SimpleStruct1.html │ │ │ │ ├── SimpleStruct2.Handler.html │ │ │ │ ├── SimpleStruct2.html │ │ │ │ ├── TestXTraceBaggage.html │ │ │ │ ├── class-use │ │ │ │ │ ├── Example.html │ │ │ │ │ ├── ExampleBag.Handler.html │ │ │ │ │ ├── ExampleBag.html │ │ │ │ │ ├── SimpleBag.Handler.html │ │ │ │ │ ├── SimpleBag.html │ │ │ │ │ ├── SimpleBag2.Handler.html │ │ │ │ │ ├── SimpleBag2.html │ │ │ │ │ ├── SimpleStruct1.Handler.html │ │ │ │ │ ├── SimpleStruct1.html │ │ │ │ │ ├── SimpleStruct2.Handler.html │ │ │ │ │ ├── SimpleStruct2.html │ │ │ │ │ └── TestXTraceBaggage.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── class-use │ │ │ ├── ActiveBaggage.html │ │ │ ├── Baggage.html │ │ │ ├── BaggageContext.html │ │ │ ├── BaggageListener.BranchListener.html │ │ │ ├── BaggageListener.JoinListener.html │ │ │ ├── BaggageListener.html │ │ │ ├── BaggageProvider.html │ │ │ ├── BaggageProviderFactory.html │ │ │ ├── DefaultBaggageProvider.html │ │ │ ├── DefaultTransitLayer.html │ │ │ ├── TestActiveBaggage.html │ │ │ ├── TestStaticAPI.html │ │ │ ├── TransitLayer.html │ │ │ └── TransitLayerFactory.html │ │ ├── impl │ │ │ ├── AtomContext.html │ │ │ ├── AtomContextProvider.html │ │ │ ├── AtomContextProviderFactory.html │ │ │ ├── BDLContext.html │ │ │ ├── BDLContextProvider.html │ │ │ ├── BDLContextProviderFactory.html │ │ │ ├── BDLContextUtils.BaggageAccessListener.html │ │ │ ├── BDLContextUtils.NullBaggageListener.html │ │ │ ├── BDLContextUtils.html │ │ │ ├── BaggageHandlerRegistry.html │ │ │ ├── NestedBaggageContext.html │ │ │ ├── NestedBaggageContextProvider.html │ │ │ ├── NestedBaggageContextProviderFactory.html │ │ │ ├── NoOpBaggageContextProvider.html │ │ │ ├── NoOpBaggageContextProviderFactory.html │ │ │ ├── NoOpTransitLayer.html │ │ │ ├── NoOpTransitLayerFactory.html │ │ │ ├── TestAtomContext.html │ │ │ ├── TestBBUtils.html │ │ │ ├── TestBaggageListener.html │ │ │ ├── TestBaggageRegistry.html │ │ │ ├── TestExampleBag.html │ │ │ ├── TestNoOpBaggageContextProvider.html │ │ │ ├── TestNoOpTransitLayer.html │ │ │ ├── TestThreadLocalTransitLayer.html │ │ │ ├── ThreadLocalTransitLayer.html │ │ │ ├── ThreadLocalTransitLayerFactory.html │ │ │ ├── class-use │ │ │ │ ├── AtomContext.html │ │ │ │ ├── AtomContextProvider.html │ │ │ │ ├── AtomContextProviderFactory.html │ │ │ │ ├── BDLContext.html │ │ │ │ ├── BDLContextProvider.html │ │ │ │ ├── BDLContextProviderFactory.html │ │ │ │ ├── BDLContextUtils.BaggageAccessListener.html │ │ │ │ ├── BDLContextUtils.NullBaggageListener.html │ │ │ │ ├── BDLContextUtils.html │ │ │ │ ├── BaggageHandlerRegistry.html │ │ │ │ ├── NestedBaggageContext.html │ │ │ │ ├── NestedBaggageContextProvider.html │ │ │ │ ├── NestedBaggageContextProviderFactory.html │ │ │ │ ├── NoOpBaggageContextProvider.html │ │ │ │ ├── NoOpBaggageContextProviderFactory.html │ │ │ │ ├── NoOpTransitLayer.html │ │ │ │ ├── NoOpTransitLayerFactory.html │ │ │ │ ├── TestAtomContext.html │ │ │ │ ├── TestBBUtils.html │ │ │ │ ├── TestBaggageListener.html │ │ │ │ ├── TestBaggageRegistry.html │ │ │ │ ├── TestExampleBag.html │ │ │ │ ├── TestNoOpBaggageContextProvider.html │ │ │ │ ├── TestNoOpTransitLayer.html │ │ │ │ ├── TestThreadLocalTransitLayer.html │ │ │ │ ├── ThreadLocalTransitLayer.html │ │ │ │ └── ThreadLocalTransitLayerFactory.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ └── xtrace │ │ ├── XTraceBaggage.Handler.html │ │ ├── XTraceBaggage.html │ │ ├── class-use │ │ ├── XTraceBaggage.Handler.html │ │ └── XTraceBaggage.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html ├── constant-values.html ├── deprecated-list.html ├── figures │ ├── baggage.png │ └── narrowwaist.png ├── help-doc.html ├── index-files │ ├── index-1.html │ ├── index-10.html │ ├── index-11.html │ ├── index-12.html │ ├── index-13.html │ ├── index-14.html │ ├── index-15.html │ ├── index-16.html │ ├── index-17.html │ ├── index-18.html │ ├── index-19.html │ ├── index-2.html │ ├── index-20.html │ ├── index-21.html │ ├── index-22.html │ ├── index-23.html │ ├── index-24.html │ ├── index-3.html │ ├── index-4.html │ ├── index-5.html │ ├── index-6.html │ ├── index-7.html │ ├── index-8.html │ └── index-9.html ├── index.html ├── javadoc-stylesheet.css ├── javadoc │ ├── allclasses-frame.html │ ├── allclasses-noframe.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── edu │ │ └── brown │ │ │ ├── cs │ │ │ └── systems │ │ │ │ ├── baggage_buffers │ │ │ │ └── gen │ │ │ │ │ └── example │ │ │ │ │ ├── ExampleBag.Handler.html │ │ │ │ │ ├── ExampleBag.html │ │ │ │ │ ├── SimpleBag.Handler.html │ │ │ │ │ ├── SimpleBag.html │ │ │ │ │ ├── SimpleBag2.Handler.html │ │ │ │ │ ├── SimpleBag2.html │ │ │ │ │ ├── class-use │ │ │ │ │ ├── ExampleBag.Handler.html │ │ │ │ │ ├── ExampleBag.html │ │ │ │ │ ├── SimpleBag.Handler.html │ │ │ │ │ ├── SimpleBag.html │ │ │ │ │ ├── SimpleBag2.Handler.html │ │ │ │ │ └── SimpleBag2.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── baggage_buffers_examples │ │ │ │ ├── Example.html │ │ │ │ ├── TestExampleBag.html │ │ │ │ ├── TestXTraceMetadata.html │ │ │ │ ├── XTraceExample.html │ │ │ │ ├── class-use │ │ │ │ │ ├── Example.html │ │ │ │ │ ├── TestExampleBag.html │ │ │ │ │ ├── TestXTraceMetadata.html │ │ │ │ │ └── XTraceExample.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ │ └── tracingplane │ │ │ │ ├── atom_layer │ │ │ │ ├── AtomLayer.html │ │ │ │ ├── AtomLayerCompatibility.html │ │ │ │ ├── AtomLayerConfig.html │ │ │ │ ├── AtomLayerFactory.TransitLayerFactoryImpl.html │ │ │ │ ├── AtomLayerFactory.html │ │ │ │ ├── BaggageAtoms.html │ │ │ │ ├── class-use │ │ │ │ │ ├── AtomLayer.html │ │ │ │ │ ├── AtomLayerCompatibility.html │ │ │ │ │ ├── AtomLayerConfig.html │ │ │ │ │ ├── AtomLayerFactory.TransitLayerFactoryImpl.html │ │ │ │ │ ├── AtomLayerFactory.html │ │ │ │ │ └── BaggageAtoms.html │ │ │ │ ├── impl │ │ │ │ │ ├── RawAtomLayer.html │ │ │ │ │ ├── RawAtomLayerFactory.html │ │ │ │ │ ├── RawBaggageAtoms.SimpleBaggageContents.html │ │ │ │ │ ├── RawBaggageAtoms.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── RawAtomLayer.html │ │ │ │ │ │ ├── RawAtomLayerFactory.html │ │ │ │ │ │ ├── RawBaggageAtoms.SimpleBaggageContents.html │ │ │ │ │ │ └── RawBaggageAtoms.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ ├── package-use.html │ │ │ │ ├── protocol │ │ │ │ │ ├── AtomLayerOverflow.TrimExtent.html │ │ │ │ │ ├── AtomLayerOverflow.html │ │ │ │ │ ├── AtomLayerSerialization.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── AtomLayerOverflow.TrimExtent.html │ │ │ │ │ │ ├── AtomLayerOverflow.html │ │ │ │ │ │ └── AtomLayerSerialization.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ └── types │ │ │ │ │ ├── AtomLayerException.html │ │ │ │ │ ├── ByteBuffers.html │ │ │ │ │ ├── Lexicographic.html │ │ │ │ │ ├── MergeIterator.IteratorContainer.html │ │ │ │ │ ├── MergeIterator.html │ │ │ │ │ ├── MergeTwoIterator.html │ │ │ │ │ ├── ProtobufVarint.EndOfStreamException.html │ │ │ │ │ ├── ProtobufVarint.MalformedVarintException.html │ │ │ │ │ ├── ProtobufVarint.html │ │ │ │ │ ├── SignedLexVarint.html │ │ │ │ │ ├── TypeUtils.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.PureJavaComparator.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.UnsafeComparator.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.html │ │ │ │ │ ├── UnsignedByteBuffer.html │ │ │ │ │ ├── UnsignedLexVarint.html │ │ │ │ │ ├── class-use │ │ │ │ │ ├── AtomLayerException.html │ │ │ │ │ ├── ByteBuffers.html │ │ │ │ │ ├── Lexicographic.html │ │ │ │ │ ├── MergeIterator.IteratorContainer.html │ │ │ │ │ ├── MergeIterator.html │ │ │ │ │ ├── MergeTwoIterator.html │ │ │ │ │ ├── ProtobufVarint.EndOfStreamException.html │ │ │ │ │ ├── ProtobufVarint.MalformedVarintException.html │ │ │ │ │ ├── ProtobufVarint.html │ │ │ │ │ ├── SignedLexVarint.html │ │ │ │ │ ├── TypeUtils.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.PureJavaComparator.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.UnsafeComparator.html │ │ │ │ │ ├── UnsignedByteBuffer.LexicographicalComparatorHolder.html │ │ │ │ │ ├── UnsignedByteBuffer.html │ │ │ │ │ └── UnsignedLexVarint.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── baggage_buffers │ │ │ │ ├── BaggageBuffers.html │ │ │ │ ├── BaggageBuffersConfig.html │ │ │ │ ├── BaggageBuffersContents.html │ │ │ │ ├── BaggageLayerFactoryImpl.html │ │ │ │ ├── Registrations.html │ │ │ │ ├── api │ │ │ │ │ ├── Bag.html │ │ │ │ │ ├── BaggageHandler.html │ │ │ │ │ ├── Brancher.html │ │ │ │ │ ├── Joiner.html │ │ │ │ │ ├── Parser.ElementParser.html │ │ │ │ │ ├── Parser.html │ │ │ │ │ ├── Serializer.ElementSerializer.html │ │ │ │ │ ├── Serializer.html │ │ │ │ │ ├── XTrace.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── Bag.html │ │ │ │ │ │ ├── BaggageHandler.html │ │ │ │ │ │ ├── Brancher.html │ │ │ │ │ │ ├── Joiner.html │ │ │ │ │ │ ├── Parser.ElementParser.html │ │ │ │ │ │ ├── Parser.html │ │ │ │ │ │ ├── Serializer.ElementSerializer.html │ │ │ │ │ │ ├── Serializer.html │ │ │ │ │ │ └── XTrace.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── class-use │ │ │ │ │ ├── BaggageBuffers.html │ │ │ │ │ ├── BaggageBuffersConfig.html │ │ │ │ │ ├── BaggageBuffersContents.html │ │ │ │ │ ├── BaggageLayerFactoryImpl.html │ │ │ │ │ └── Registrations.html │ │ │ │ ├── compiler │ │ │ │ │ ├── BBC.Settings.html │ │ │ │ │ ├── BBC.html │ │ │ │ │ ├── CompileException.html │ │ │ │ │ ├── Compiler.html │ │ │ │ │ ├── FileUtils.html │ │ │ │ │ ├── JavaCompilerUtils.html │ │ │ │ │ ├── Linker.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── BBC.Settings.html │ │ │ │ │ │ ├── BBC.html │ │ │ │ │ │ ├── CompileException.html │ │ │ │ │ │ ├── Compiler.html │ │ │ │ │ │ ├── FileUtils.html │ │ │ │ │ │ ├── JavaCompilerUtils.html │ │ │ │ │ │ └── Linker.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── gen │ │ │ │ │ └── xtrace │ │ │ │ │ │ ├── XTrace.html │ │ │ │ │ │ ├── XTraceParser.html │ │ │ │ │ │ ├── XTraceSerializer.html │ │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── XTrace.html │ │ │ │ │ │ ├── XTraceParser.html │ │ │ │ │ │ └── XTraceSerializer.html │ │ │ │ │ │ ├── package-frame.html │ │ │ │ │ │ ├── package-summary.html │ │ │ │ │ │ ├── package-tree.html │ │ │ │ │ │ └── package-use.html │ │ │ │ ├── impl │ │ │ │ │ ├── BBUtils.html │ │ │ │ │ ├── Branchers.html │ │ │ │ │ ├── Cast.html │ │ │ │ │ ├── Joiners.html │ │ │ │ │ ├── Parsers.html │ │ │ │ │ ├── ReaderHelpers.html │ │ │ │ │ ├── Serializers.html │ │ │ │ │ ├── WriterHelpers.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── BBUtils.html │ │ │ │ │ │ ├── Branchers.html │ │ │ │ │ │ ├── Cast.html │ │ │ │ │ │ ├── Joiners.html │ │ │ │ │ │ ├── Parsers.html │ │ │ │ │ │ ├── ReaderHelpers.html │ │ │ │ │ │ ├── Serializers.html │ │ │ │ │ │ └── WriterHelpers.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ │ ├── baggage_layer │ │ │ │ ├── BagKey.BagPath.html │ │ │ │ ├── BagKey.Indexed.html │ │ │ │ ├── BagKey.Keyed.html │ │ │ │ ├── BagKey.html │ │ │ │ ├── BagOptions.MergeBehavior.html │ │ │ │ ├── BagOptions.html │ │ │ │ ├── BaggageContents.html │ │ │ │ ├── BaggageLayer.html │ │ │ │ ├── BaggageLayerConfig.html │ │ │ │ ├── BaggageLayerException.BaggageLayerRuntimeException.html │ │ │ │ ├── BaggageLayerException.html │ │ │ │ ├── BaggageLayerFactory.AtomLayerFactoryImpl.html │ │ │ │ ├── BaggageLayerFactory.html │ │ │ │ ├── class-use │ │ │ │ │ ├── BagKey.BagPath.html │ │ │ │ │ ├── BagKey.Indexed.html │ │ │ │ │ ├── BagKey.Keyed.html │ │ │ │ │ ├── BagKey.html │ │ │ │ │ ├── BagOptions.MergeBehavior.html │ │ │ │ │ ├── BagOptions.html │ │ │ │ │ ├── BaggageContents.html │ │ │ │ │ ├── BaggageLayer.html │ │ │ │ │ ├── BaggageLayerConfig.html │ │ │ │ │ ├── BaggageLayerException.BaggageLayerRuntimeException.html │ │ │ │ │ ├── BaggageLayerException.html │ │ │ │ │ ├── BaggageLayerFactory.AtomLayerFactoryImpl.html │ │ │ │ │ └── BaggageLayerFactory.html │ │ │ │ ├── impl │ │ │ │ │ ├── GenericBaggageContents.html │ │ │ │ │ ├── GenericBaggageContentsParser.html │ │ │ │ │ ├── GenericBaggageContentsSerializer.html │ │ │ │ │ ├── GenericBaggageLayer.html │ │ │ │ │ ├── GenericBaggageLayerFactory.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ ├── GenericBaggageContents.html │ │ │ │ │ │ ├── GenericBaggageContentsParser.html │ │ │ │ │ │ ├── GenericBaggageContentsSerializer.html │ │ │ │ │ │ ├── GenericBaggageLayer.html │ │ │ │ │ │ └── GenericBaggageLayerFactory.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ ├── package-use.html │ │ │ │ └── protocol │ │ │ │ │ ├── AtomPrefixTypes.AtomType.html │ │ │ │ │ ├── AtomPrefixTypes.BagOptionsInPrefix.html │ │ │ │ │ ├── AtomPrefixTypes.HeaderType.html │ │ │ │ │ ├── AtomPrefixTypes.Level.html │ │ │ │ │ ├── AtomPrefixTypes.html │ │ │ │ │ ├── AtomPrefixes.AtomPrefix.html │ │ │ │ │ ├── AtomPrefixes.DataPrefix.html │ │ │ │ │ ├── AtomPrefixes.HeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.IndexedHeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.KeyedHeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.UnsupportedPrefix.html │ │ │ │ │ ├── AtomPrefixes.html │ │ │ │ │ ├── BaggageReader.html │ │ │ │ │ ├── BaggageWriter.SharedBackingBuffer.html │ │ │ │ │ ├── BaggageWriter.html │ │ │ │ │ ├── ElementReader.html │ │ │ │ │ ├── ElementWriter.html │ │ │ │ │ ├── HeaderSerialization.html │ │ │ │ │ ├── Parser.html │ │ │ │ │ ├── Serializer.html │ │ │ │ │ ├── class-use │ │ │ │ │ ├── AtomPrefixTypes.AtomType.html │ │ │ │ │ ├── AtomPrefixTypes.BagOptionsInPrefix.html │ │ │ │ │ ├── AtomPrefixTypes.HeaderType.html │ │ │ │ │ ├── AtomPrefixTypes.Level.html │ │ │ │ │ ├── AtomPrefixTypes.html │ │ │ │ │ ├── AtomPrefixes.AtomPrefix.html │ │ │ │ │ ├── AtomPrefixes.DataPrefix.html │ │ │ │ │ ├── AtomPrefixes.HeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.IndexedHeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.KeyedHeaderPrefix.html │ │ │ │ │ ├── AtomPrefixes.UnsupportedPrefix.html │ │ │ │ │ ├── AtomPrefixes.html │ │ │ │ │ ├── BaggageReader.html │ │ │ │ │ ├── BaggageWriter.SharedBackingBuffer.html │ │ │ │ │ ├── BaggageWriter.html │ │ │ │ │ ├── ElementReader.html │ │ │ │ │ ├── ElementWriter.html │ │ │ │ │ ├── HeaderSerialization.html │ │ │ │ │ ├── Parser.html │ │ │ │ │ └── Serializer.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ └── transit_layer │ │ │ │ ├── Baggage.html │ │ │ │ ├── ThreadLocalBaggage.html │ │ │ │ ├── TransitLayer.html │ │ │ │ ├── TransitLayerCompatibility.html │ │ │ │ ├── TransitLayerConfig.html │ │ │ │ ├── TransitLayerFactory.html │ │ │ │ ├── class-use │ │ │ │ ├── Baggage.html │ │ │ │ ├── ThreadLocalBaggage.html │ │ │ │ ├── TransitLayer.html │ │ │ │ ├── TransitLayerCompatibility.html │ │ │ │ ├── TransitLayerConfig.html │ │ │ │ └── TransitLayerFactory.html │ │ │ │ ├── impl │ │ │ │ ├── NullBaggage.html │ │ │ │ ├── NullTransitLayer.html │ │ │ │ ├── NullTransitLayerFactory.html │ │ │ │ ├── class-use │ │ │ │ │ ├── NullBaggage.html │ │ │ │ │ ├── NullTransitLayer.html │ │ │ │ │ └── NullTransitLayerFactory.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ └── xtrace │ │ │ ├── XTraceMetadata.Handler.html │ │ │ ├── XTraceMetadata.html │ │ │ ├── class-use │ │ │ ├── XTraceMetadata.Handler.html │ │ │ └── XTraceMetadata.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ ├── help-doc.html │ ├── index-files │ │ ├── index-1.html │ │ ├── index-10.html │ │ ├── index-11.html │ │ ├── index-12.html │ │ ├── index-13.html │ │ ├── index-14.html │ │ ├── index-15.html │ │ ├── index-16.html │ │ ├── index-17.html │ │ ├── index-18.html │ │ ├── index-19.html │ │ ├── index-2.html │ │ ├── index-20.html │ │ ├── index-21.html │ │ ├── index-22.html │ │ ├── index-23.html │ │ ├── index-24.html │ │ ├── index-3.html │ │ ├── index-4.html │ │ ├── index-5.html │ │ ├── index-6.html │ │ ├── index-7.html │ │ ├── index-8.html │ │ └── index-9.html │ ├── index.html │ ├── javadoc-stylesheet.css │ ├── overview-frame.html │ ├── overview-summary.html │ ├── overview-tree.html │ ├── package-list │ ├── script.js │ └── serialized-form.html ├── overview-frame.html ├── overview-summary.html ├── overview-tree.html ├── package-list ├── script.js ├── serialized-form.html └── transit-layer-tutorial.md ├── pom.xml └── resources ├── BaggageEclipseSettings.xml ├── javadoc-stylesheet.css ├── javadoc.xml └── log4j-surefire.properties /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | .tmpBin 3 | .cache 4 | .cache-tests 5 | .idea 6 | *.cache-main 7 | *.iml 8 | .couscous 9 | target 10 | .classpath 11 | .settings 12 | .project 13 | .DS_Store 14 | resources/bbc.jar 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Brown University 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /atomlayer/baggagecontext-impl/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /atomlayer/baggagecontext-impl/README.md: -------------------------------------------------------------------------------- 1 | # TracingPlane:AtomLayer/BaggageContext 2 | 3 | This package implements a `BaggageContext` based solely on atoms and lexicographic merge. It provides no interpretation of the atoms, but does provide an implementation of the main `BaggageProvider` methods -- specifically serialization, merge/join, and trim. 4 | 5 | This atom-only `BaggageContext` should be used in systems that wish to propagate baggage, but have no need to inspect or modify its contents (e.g., if baggage is just passing through). For this use case, none of the more heavyweight libraries (e.g., the baggage protocol and BDL client library) are necessary. -------------------------------------------------------------------------------- /atomlayer/baggagecontext-impl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | atomlayer-baggagecontext 6 | jar 7 | 8 | Atom Layer - BaggageContext Impl 9 | 10 | 11 | brown.tracingplane 12 | atomlayer 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | atomlayer-core 24 | ${project.version} 25 | 26 | 27 | com.typesafe 28 | config 29 | 30 | 31 | junit 32 | junit 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /atomlayer/baggagecontext-impl/src/main/java/brown/tracingplane/impl/AtomContextProvider.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.List; 5 | import brown.tracingplane.BaggageContext; 6 | import brown.tracingplane.BaggageProvider; 7 | import brown.tracingplane.atomlayer.AtomLayerSerialization; 8 | 9 | /** 10 | *

11 | * {@link BaggageProvider} for {@link AtomContext}, a minimal {@link BaggageContext} based on atoms and lexicographic merge. 12 | *

13 | */ 14 | public class AtomContextProvider implements BaggageProvider { 15 | 16 | @Override 17 | public boolean isValid(BaggageContext baggageContext) { 18 | return baggageContext == null || baggageContext instanceof AtomContext; 19 | } 20 | 21 | @Override 22 | public AtomContext newInstance() { 23 | return null; 24 | } 25 | 26 | @Override 27 | public void discard(AtomContext baggageContext) { 28 | if (baggageContext != null) { 29 | baggageContext.discard(); 30 | } 31 | } 32 | 33 | @Override 34 | public AtomContext branch(AtomContext from) { 35 | return from == null ? null : from.branch(); 36 | } 37 | 38 | @Override 39 | public AtomContext join(AtomContext left, AtomContext right) { 40 | return left == null ? right : left.merge(right); 41 | } 42 | 43 | @Override 44 | public AtomContext deserialize(byte[] serialized, int offset, int length) { 45 | return wrap(AtomLayerSerialization.deserialize(serialized, offset, length)); 46 | } 47 | 48 | @Override 49 | public AtomContext deserialize(ByteBuffer buf) { 50 | return wrap(AtomLayerSerialization.deserialize(buf)); 51 | } 52 | 53 | @Override 54 | public byte[] serialize(AtomContext baggageContext) { 55 | return AtomLayerSerialization.serialize(atoms(baggageContext)); 56 | } 57 | 58 | @Override 59 | public byte[] serialize(AtomContext baggageContext, int maximumSerializedSize) { 60 | return AtomLayerSerialization.serialize(atoms(baggageContext), maximumSerializedSize); 61 | } 62 | 63 | AtomContext wrap(List atoms) { 64 | if (atoms == null || atoms.size() == 0) { 65 | return null; 66 | } else { 67 | return new AtomContext(atoms); 68 | } 69 | } 70 | 71 | List atoms(AtomContext baggageContext) { 72 | return baggageContext == null ? null : baggageContext.atoms(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /atomlayer/baggagecontext-impl/src/main/java/brown/tracingplane/impl/AtomContextProviderFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.BaggageContext; 4 | import brown.tracingplane.BaggageProvider; 5 | import brown.tracingplane.BaggageProviderFactory; 6 | 7 | /** 8 | * {@link BaggageProviderFactory} for {@link AtomContextProvider} 9 | */ 10 | public class AtomContextProviderFactory implements BaggageProviderFactory { 11 | 12 | @Override 13 | public BaggageProvider provider() { 14 | return new AtomContextProvider(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /atomlayer/core/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /atomlayer/core/README.md: -------------------------------------------------------------------------------- 1 | # TracingPlane:AtomLayer/Core 2 | 3 | This package provides the core representation and implementations for the Tracing Plane's *atom* based `BaggageContext` implementation. This includes utility classes and methods based around lexicographic comparison and atom merging. -------------------------------------------------------------------------------- /atomlayer/core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | atomlayer-core 6 | jar 7 | 8 | Atom Layer - Core 9 | 10 | 11 | brown.tracingplane 12 | atomlayer 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggagecontext-api 24 | ${project.version} 25 | 26 | 27 | org.slf4j 28 | slf4j-api 29 | 30 | 31 | org.slf4j 32 | slf4j-log4j12 33 | 34 | 35 | com.google.guava 36 | guava 37 | 38 | 39 | junit 40 | junit 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/AtomLayerException.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import java.nio.BufferUnderflowException; 4 | 5 | public class AtomLayerException extends Exception { 6 | 7 | private static final long serialVersionUID = -658006356579507967L; 8 | 9 | public AtomLayerException(String message) { 10 | super(message); 11 | } 12 | 13 | public AtomLayerException(String message, BufferUnderflowException e) { 14 | super(message, e); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/ByteBuffers.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Comparator; 5 | 6 | /** 7 | * Some functions I found useful for working with byte buffers 8 | */ 9 | public class ByteBuffers { 10 | 11 | public static final Comparator LEXICOGRAPHIC_COMPARATOR = 12 | UnsignedByteBuffer.lexicographicalComparator(); 13 | 14 | /** 15 | *

Copies all remaining bytes from src to dest. This is done without modifying the src's position. However, the 16 | * dest's position is updated.

17 | * 18 | * @param src the buffer to copy from. its position will not be updated. 19 | * @param dest the buffer to copy to. its position will be updated. 20 | */ 21 | public static void copyTo(ByteBuffer src, ByteBuffer dest) { 22 | if (src == null || dest == null) { 23 | return; 24 | } 25 | if (src.hasArray()) { 26 | byte[] array = src.array(); 27 | int offset = src.arrayOffset() + src.position(); 28 | int length = src.remaining(); 29 | dest.put(array, offset, length); 30 | } else { 31 | for (int i = src.position(); i < src.limit(); i++) { 32 | dest.put(src.get(i)); 33 | } 34 | } 35 | } 36 | 37 | public static ByteBuffer copyWithPrefix(byte prefix, ByteBuffer src) { 38 | ByteBuffer buf = ByteBuffer.allocate(src.remaining() + 1); 39 | buf.put(prefix); 40 | copyTo(src, buf); 41 | buf.position(0); 42 | return buf; 43 | } 44 | 45 | /** 46 | * Copies the remaining bytes form src to a new byte buffer. This is done without modifying the src position. The 47 | * dest position will be 0. 48 | */ 49 | public static ByteBuffer copyRemaining(ByteBuffer src) { 50 | ByteBuffer buf = ByteBuffer.allocate(src.remaining()); 51 | copyTo(src, buf); 52 | buf.position(0); 53 | return buf; 54 | } 55 | 56 | /** Copies the remaining bytes form src to a byte array. This is done without modifying the src position. */ 57 | public static byte[] copyRemainingBytes(ByteBuffer src) { 58 | return copyRemaining(src).array(); 59 | } 60 | 61 | /** Read the remaining bytes from a bytebuffer as a string */ 62 | public static String getString(ByteBuffer buf) { 63 | if (buf == null) { 64 | return null; 65 | } 66 | 67 | final byte[] array; 68 | final int offset; 69 | final int length = buf.remaining(); 70 | if (buf.hasArray()) { 71 | array = buf.array(); 72 | offset = buf.arrayOffset() + buf.position(); 73 | } else { 74 | array = new byte[length]; 75 | offset = 0; 76 | buf.get(array); 77 | } 78 | return new String(array, offset, length); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/MergeIterator.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * Merges multiple iterators and produces elements according to the provided comparator. 11 | *

12 | *

13 | * The input iterators do not need to be sorted. However, if two iterators produce the same element at the same time, 14 | * the element will only be output once. 15 | *

16 | * 17 | *

18 | * eg, for inputs [1, 2, 3] and [0, 1, 2], the output will be [0, 1, 2, 3]
19 | * however, for inputs [1, 2, 1] and [1, 3, 2], the output will be [1, 2, 1, 3, 2] 20 | *

21 | * 22 | * 23 | * @param 24 | */ 25 | public class MergeIterator implements Iterator { 26 | 27 | private class IteratorContainer { 28 | 29 | final Iterator it; 30 | T next; 31 | 32 | public IteratorContainer(Iterator it) { 33 | this.it = it; 34 | this.next = it.next(); 35 | } 36 | 37 | void advance() { 38 | next = it.hasNext() ? it.next() : null; 39 | } 40 | 41 | } 42 | 43 | private final Comparator comparator; 44 | private final List iterators; 45 | private final List iteratorsWithNextValue; 46 | private T nextValue = null; 47 | 48 | private MergeIterator(Comparator comparator, int size) { 49 | this.comparator = comparator; 50 | this.iterators = new ArrayList<>(size); 51 | this.iteratorsWithNextValue = new ArrayList<>(size); 52 | this.nextValue = null; 53 | } 54 | 55 | public MergeIterator(Comparator comparator, @SuppressWarnings("unchecked") Iterator... iterators) { 56 | this(comparator, iterators.length); 57 | 58 | for (Iterator it : iterators) { 59 | if (it != null && it.hasNext()) { 60 | this.iterators.add(new IteratorContainer(it)); 61 | } 62 | } 63 | 64 | advance(); 65 | } 66 | 67 | public MergeIterator(List> iterators, Comparator comparator) { 68 | this(comparator, iterators.size()); 69 | 70 | for (Iterator it : iterators) { 71 | if (it != null && it.hasNext()) { 72 | this.iterators.add(new IteratorContainer(it)); 73 | } 74 | } 75 | 76 | advance(); 77 | } 78 | 79 | private void advance() { 80 | // Advance all of the iterators that produced the previous value 81 | for (IteratorContainer it : iteratorsWithNextValue) { 82 | it.advance(); 83 | if (it.next == null) { 84 | iterators.remove(it); 85 | } 86 | } 87 | 88 | // Get the next min value 89 | T next = null; 90 | for (IteratorContainer it : iterators) { 91 | int comparison = next == null ? -1 : comparator.compare(it.next, next); 92 | if (comparison < 0) { 93 | next = it.next; 94 | iteratorsWithNextValue.clear(); 95 | iteratorsWithNextValue.add(it); 96 | } else if (comparison == 0) { 97 | iteratorsWithNextValue.add(it); 98 | } 99 | } 100 | nextValue = next; 101 | } 102 | 103 | @Override 104 | public boolean hasNext() { 105 | return nextValue != null; 106 | } 107 | 108 | @Override 109 | public T next() { 110 | T ret = nextValue; 111 | advance(); 112 | return ret; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/MergeTwoIterator.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import java.util.Comparator; 4 | import java.util.Iterator; 5 | 6 | /** Like {@link MergeIterator} but for two iterators only */ 7 | public class MergeTwoIterator implements Iterator { 8 | 9 | private final Iterator a; 10 | private final Iterator b; 11 | 12 | private T nexta = null; 13 | private T nextb = null; 14 | private Comparator comparator; 15 | 16 | public MergeTwoIterator(Iterator a, Iterator b, Comparator comparator) { 17 | this.a = a; 18 | this.b = b; 19 | this.comparator = comparator; 20 | advanceA(); 21 | advanceB(); 22 | } 23 | 24 | private void advanceA() { 25 | if (a.hasNext()) { 26 | nexta = a.next(); 27 | } else { 28 | nexta = null; 29 | } 30 | } 31 | 32 | private void advanceB() { 33 | if (b.hasNext()) { 34 | nextb = b.next(); 35 | } else { 36 | nextb = null; 37 | } 38 | } 39 | 40 | @Override 41 | public boolean hasNext() { 42 | return nexta != null || nextb != null; 43 | } 44 | 45 | @Override 46 | public T next() { 47 | T result = null; 48 | if (nexta == null) { 49 | result = nextb; 50 | advanceB(); 51 | } else if (nextb == null) { 52 | result = nexta; 53 | advanceA(); 54 | } else { 55 | int comparison = comparator.compare(nexta, nextb); 56 | if (comparison < 0) { 57 | result = nexta; 58 | advanceA(); 59 | } else if (comparison == 0) { 60 | result = nexta; 61 | advanceA(); 62 | advanceB(); 63 | } else { 64 | result = nextb; 65 | advanceB(); 66 | } 67 | } 68 | return result; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/StringUtils.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | /** 4 | * Want to avoid having apache commons as a dependency, so implement any functions used here 5 | */ 6 | public class StringUtils { 7 | 8 | public static String join(Iterable objects, String separator) { 9 | if (objects == null) return ""; 10 | StringBuilder b = new StringBuilder(); 11 | boolean first = true; 12 | for (Object s : objects) { 13 | if (!first) { 14 | b.append(separator); 15 | } else { 16 | first = false; 17 | } 18 | b.append(String.valueOf(s)); 19 | } 20 | return b.toString(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/TypeUtils.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Some useful utility methods related to bits and bytes 9 | */ 10 | public class TypeUtils { 11 | 12 | private TypeUtils() {} 13 | 14 | public static String toBinaryString(byte b) { 15 | return String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'); 16 | } 17 | 18 | public static String toHexString(byte b) { 19 | return String.format("%2s", Integer.toHexString(b & 0xFF)).replace(' ', '0').toUpperCase(); 20 | } 21 | 22 | public static byte makeByte(String bitPattern) { 23 | bitPattern = bitPattern.replaceAll(" ", ""); 24 | int[] ints = new int[bitPattern.length()]; 25 | for (int i = 0; i < bitPattern.length(); i++) { 26 | ints[i] = Integer.valueOf(bitPattern.substring(i, i + 1)); 27 | } 28 | return makeByte(ints); 29 | } 30 | 31 | public static byte makeByte(int... bitPattern) { 32 | byte result = 0; 33 | for (int bit : bitPattern) { 34 | result = (byte) ((result << 1) ^ (bit == 0 ? 0 : 1)); 35 | } 36 | return result; 37 | } 38 | 39 | public static int offset(byte mask) { 40 | for (int i = 1; i <= 8; i++) { 41 | if (((mask >> i) << i) != mask) { 42 | return i - 1; 43 | } 44 | } 45 | return 8; 46 | } 47 | 48 | public static String toBinaryString(ByteBuffer atom) { 49 | List binaryStrings = new ArrayList<>(); 50 | for (int i = atom.position(); i < atom.limit(); i++) { 51 | binaryStrings.add(toBinaryString(atom.get(i))); 52 | } 53 | return String.format("[%s]", StringUtils.join(binaryStrings, ", ")); 54 | } 55 | 56 | public static String toHexString(ByteBuffer atom) { 57 | List hexStrings = new ArrayList<>(); 58 | for (int i = atom.position(); i < atom.limit(); i++) { 59 | hexStrings.add(toHexString(atom.get(i))); 60 | } 61 | return String.format("%s", StringUtils.join(hexStrings, "")); 62 | } 63 | 64 | public static String toBinaryString(Iterable atoms) { 65 | List binaryStrings = new ArrayList<>(); 66 | for (ByteBuffer atom : atoms) { 67 | binaryStrings.add(toBinaryString(atom)); 68 | } 69 | return String.format("[%s]", StringUtils.join(binaryStrings, ", ")); 70 | } 71 | 72 | public static String toHexString(Iterable atoms) { 73 | return toHexString(atoms, ", "); 74 | } 75 | 76 | public static String toHexString(Iterable atoms, String atomSeparator) { 77 | List hexStrings = new ArrayList<>(); 78 | for (ByteBuffer atom : atoms) { 79 | hexStrings.add(toHexString(atom)); 80 | } 81 | return String.format("%s", StringUtils.join(hexStrings, atomSeparator)); 82 | } 83 | 84 | public static String toHexString(byte[] serialize) { 85 | return toHexString(ByteBuffer.wrap(serialize)); 86 | } 87 | 88 | public static String toHexString(String s) { 89 | List hexStrings = new ArrayList<>(); 90 | for (byte b : s.getBytes()) { 91 | hexStrings.add("`" + toHexString(b) + "`"); 92 | } 93 | return StringUtils.join(hexStrings, ","); 94 | } 95 | 96 | public static void main(String[] args) { 97 | int[] xs = { 12, 22, 30, 50, 80 }; 98 | for (int x : xs) { 99 | System.out.println(toHexString((byte) x)); 100 | } 101 | // System.out.println(toHexString("a")); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /atomlayer/core/src/main/java/brown/tracingplane/atomlayer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | *

4 | * Provides the Tracing Plane's core underlying data representation for {@link BaggageContext} based on atoms and 5 | * lexicographic merge. 6 | *

7 | * 8 | *

9 | * The key primitives provided by the Atom Layer are an intermediary data format for {@link BaggageContext}s based on 10 | * atoms, along with the default atom-based comparison and merge functions based on the lexicographic ordering of 11 | * atoms. 12 | *

13 | * 14 | *

15 | * The Atom Layer represents atoms using {@link ByteBuffer}s. 16 | *

17 | * 18 | *

19 | * This package also contains functions for encoding lexicographically consistent variable length integers. 20 | *

21 | * 22 | *

23 | * The Atom Layer provides an underlying representation for {@link BaggageContext} based on atoms. Other layers 24 | * of the tracing plane use atoms to construct data structures like sets and maps. Since the Atom Layer is an inner 25 | * layer of the Tracing Plane, it is not expected for users to have to deal with this layer directly. 26 | *

27 | * 28 | *

29 | * However, the Atom Layer does provide a minimal {@link BaggageContext} implementation that you can use to 30 | * propagate contexts. This implementation lets you propagate contexts, but you cannot update them or access their 31 | * content. 32 | *

33 | * 34 | *

35 | * The atom layer is based on the notion of atoms: an atom is an arbitrary array of zero or more bytes; and a 36 | * {@link BaggageContext} is an arbitrary array of atoms, by default empty. The interpretation of atoms is up to the 37 | * clients calling down to the atom layer, and an atom is indivisible by the atom layer. The ordering of atoms is also 38 | * up to clients; however, the atom layer's {@link BaggageProvider#join(BaggageContext, BaggageContext)} implementation 39 | * can affect the position of atoms. 40 | *

41 | */ 42 | package brown.tracingplane.atomlayer; 43 | -------------------------------------------------------------------------------- /atomlayer/core/src/test/java/brown/tracingplane/atomlayer/TestByteBuffers.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import java.nio.BufferOverflowException; 5 | import java.nio.ByteBuffer; 6 | import java.util.Random; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | import org.junit.rules.ExpectedException; 10 | import brown.tracingplane.atomlayer.ByteBuffers; 11 | 12 | public class TestByteBuffers { 13 | 14 | @Rule 15 | public final ExpectedException exception = ExpectedException.none(); 16 | 17 | @Test 18 | public void testCopyToAdvancesPositionOnlyInDest() { 19 | ByteBuffer src = ByteBuffer.allocate(10); 20 | ByteBuffer dest = ByteBuffer.allocate(10); 21 | 22 | ByteBuffers.copyTo(src, dest); 23 | assertEquals(0, src.position()); 24 | assertEquals(10, dest.position()); 25 | } 26 | 27 | @Test 28 | public void testCopyNulls() { 29 | ByteBuffers.copyTo(null, ByteBuffer.allocate(0)); 30 | ByteBuffers.copyTo(ByteBuffer.allocate(0), null); 31 | ByteBuffers.copyTo(null, null); 32 | } 33 | 34 | @Test 35 | public void testCopyInsufficientSpace() { 36 | ByteBuffer src = ByteBuffer.allocate(10); 37 | ByteBuffer dest = ByteBuffer.allocate(5); 38 | 39 | exception.expect(BufferOverflowException.class); 40 | ByteBuffers.copyTo(src, dest); 41 | } 42 | 43 | @Test 44 | public void testCopyCorrect() { 45 | Random r = new Random(0); 46 | 47 | ByteBuffer src = ByteBuffer.allocate(200); 48 | r.nextBytes(src.array()); 49 | src.position(77); 50 | src.limit(127); 51 | 52 | ByteBuffer dest = ByteBuffer.allocate(500); 53 | r.nextBytes(dest.array()); 54 | dest.position(133); 55 | dest.limit(450); 56 | 57 | ByteBuffers.copyTo(src, dest); 58 | assertEquals(77, src.position()); 59 | assertEquals(127, src.limit()); 60 | assertEquals(183, dest.position()); 61 | assertEquals(450, dest.limit()); 62 | 63 | dest.position(133); 64 | dest.limit(183); 65 | assertEquals(src, dest); 66 | } 67 | 68 | @Test 69 | public void testCopyWithPrefix() { 70 | ByteBuffer buf = ByteBuffer.allocate(4); 71 | buf.putInt(0, 55); 72 | 73 | byte prefix = 109; 74 | 75 | ByteBuffer copied = ByteBuffers.copyWithPrefix(prefix, buf); 76 | 77 | assertEquals(prefix, copied.get()); 78 | assertEquals(55, copied.getInt()); 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /atomlayer/core/src/test/java/brown/tracingplane/atomlayer/TestMerge.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | import java.nio.ByteBuffer; 5 | import java.util.List; 6 | import org.junit.Test; 7 | import com.google.common.collect.Lists; 8 | import brown.tracingplane.atomlayer.Lexicographic; 9 | import brown.tracingplane.atomlayer.TypeUtils; 10 | 11 | public class TestMerge { 12 | 13 | private static ByteBuffer make(String... ss) { 14 | ByteBuffer buf = ByteBuffer.allocate(ss.length); 15 | for (String s : ss) { 16 | buf.put(TypeUtils.makeByte(s)); 17 | } 18 | buf.rewind(); 19 | return buf; 20 | } 21 | 22 | private static boolean equals(List a, List b) { 23 | if (a.size() != b.size()) { 24 | return false; 25 | } 26 | for (int i = 0; i < a.size(); i++) { 27 | if (Lexicographic.compare(a.get(i), b.get(i)) != 0) { 28 | return false; 29 | } 30 | } 31 | return true; 32 | } 33 | 34 | @Test 35 | public void testByteBufferListMergeUnion() { 36 | List a = Lists.newArrayList(make("00000000")); 37 | 38 | List b = Lists.newArrayList(make("11111111")); 39 | 40 | List expect = Lists.newArrayList(make("00000000"), make("11111111")); 41 | 42 | assertTrue(equals(Lexicographic.merge(a, b), expect)); 43 | } 44 | 45 | @Test 46 | public void testByteBufferListMergeDuplicates() { 47 | List a = Lists.newArrayList(make("00000000"), make("11111111")); 48 | 49 | List b = Lists.newArrayList(make("00000000"), make("11111111")); 50 | 51 | List expect = Lists.newArrayList(make("00000000"), make("11111111")); 52 | 53 | assertTrue(equals(Lexicographic.merge(a, b), expect)); 54 | } 55 | 56 | @Test 57 | public void testByteBufferListMergeDuplicatesTricky() { 58 | List a = Lists.newArrayList(make("00000000"), make("11111111")); 59 | 60 | List b = Lists.newArrayList(make("11111111"), make("00000000")); 61 | 62 | List expect = Lists.newArrayList(make("00000000"), make("11111111"), make("00000000")); 63 | 64 | assertTrue(equals(Lexicographic.merge(a, b), expect)); 65 | } 66 | 67 | @Test 68 | public void testByteBufferListMergeVariableLength() { 69 | List a = Lists.newArrayList(make("00000000", "00000000", "00000000", "00000001")); 70 | 71 | List b = Lists.newArrayList(make("00000000", "00000000", "00000000", "00000001", "00000000")); 72 | 73 | List expect = Lists.newArrayList(make("00000000", "00000000", "00000000", "00000001"), 74 | make("00000000", "00000000", "00000000", "00000001", "00000000")); 75 | 76 | assertTrue(equals(Lexicographic.merge(a, b), expect)); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /atomlayer/core/src/test/java/brown/tracingplane/atomlayer/TestProtobufVarint.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import java.nio.BufferUnderflowException; 5 | import java.nio.ByteBuffer; 6 | import java.util.Random; 7 | import org.junit.Test; 8 | import brown.tracingplane.atomlayer.ProtobufVarint; 9 | import brown.tracingplane.atomlayer.ProtobufVarint.MalformedVarintException; 10 | 11 | public class TestProtobufVarint { 12 | 13 | @Test 14 | public void testVarintSize() { 15 | int numtests = 1000; 16 | Random r = new Random(0); 17 | for (int i = 0; i < 5; i++) { 18 | int min = (int) Math.pow(2, 7 * i); 19 | int max = (int) Math.min(Integer.MAX_VALUE, Math.pow(2, 7 * (i + 1))); 20 | 21 | for (int j = 0; j < numtests; j++) { 22 | int value = r.nextInt(max - min) + min; 23 | assertEquals(i + 1, ProtobufVarint.sizeOf(value)); 24 | } 25 | } 26 | } 27 | 28 | @Test 29 | public void testVarintCorrect() throws MalformedVarintException, BufferUnderflowException { 30 | int numtests = 1000; 31 | Random r = new Random(0); 32 | for (int i = 0; i < 5; i++) { 33 | int min = (int) Math.pow(2, 7 * i); 34 | int max = (int) Math.min(Integer.MAX_VALUE, Math.pow(2, 7 * (i + 1))); 35 | 36 | for (int j = 0; j < numtests; j++) { 37 | int value = r.nextInt(max - min) + min; 38 | 39 | ByteBuffer b = ByteBuffer.allocate(i + 1); 40 | ProtobufVarint.writeRawVarint32(b, value); 41 | b.rewind(); 42 | 43 | assertEquals(value, ProtobufVarint.readRawVarint32(b)); 44 | } 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /atomlayer/core/src/test/java/brown/tracingplane/atomlayer/TestSerialization.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import java.nio.ByteBuffer; 6 | import java.util.ArrayList; 7 | import org.junit.Test; 8 | import brown.tracingplane.atomlayer.AtomLayerSerialization; 9 | 10 | public class TestSerialization { 11 | 12 | @Test 13 | public void testSerializeNulls() { 14 | 15 | assertNotNull(AtomLayerSerialization.serialize(null)); 16 | assertNotNull(AtomLayerSerialization.serialize(new ArrayList())); 17 | 18 | assertEquals(0, AtomLayerSerialization.serialize(null).length); 19 | assertEquals(0, AtomLayerSerialization.serialize(new ArrayList()).length); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /atomlayer/core/src/test/java/brown/tracingplane/atomlayer/TestUnsignedByteBuffer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.atomlayer; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | import java.nio.ByteBuffer; 5 | import java.util.Comparator; 6 | import org.junit.Test; 7 | import brown.tracingplane.atomlayer.TypeUtils; 8 | import brown.tracingplane.atomlayer.UnsignedByteBuffer; 9 | 10 | public class TestUnsignedByteBuffer { 11 | 12 | private static ByteBuffer make(String... ss) { 13 | ByteBuffer buf = ByteBuffer.allocate(ss.length); 14 | for (String s : ss) { 15 | buf.put(TypeUtils.makeByte(s)); 16 | } 17 | buf.rewind(); 18 | return buf; 19 | } 20 | 21 | @Test 22 | public void testUnsafeComparatorExists() { 23 | Comparator comparator = UnsignedByteBuffer.lexicographicalComparator(); 24 | 25 | assertTrue(comparator instanceof UnsignedByteBuffer.LexicographicalComparatorHolder.UnsafeComparator); 26 | } 27 | 28 | @Test 29 | public void testJavaComparatorExists() { 30 | Comparator comparator = UnsignedByteBuffer.lexicographicalComparatorJavaImpl(); 31 | 32 | assertTrue(comparator instanceof UnsignedByteBuffer.LexicographicalComparatorHolder.PureJavaComparator); 33 | } 34 | 35 | @Test 36 | public void testUnsafeComparator() { 37 | Comparator comparator = UnsignedByteBuffer.lexicographicalComparator(); 38 | 39 | ByteBuffer a = make("0000 0000"); 40 | ByteBuffer b = make("1000 0000"); 41 | 42 | assertTrue(comparator.compare(a, a) == 0); 43 | assertTrue(comparator.compare(b, b) == 0); 44 | assertTrue(comparator.compare(a, b) < 0); 45 | assertTrue(comparator.compare(b, a) > 0); 46 | } 47 | 48 | @Test 49 | public void testUnsafeComparatorWithLong() { 50 | Comparator comparator = UnsignedByteBuffer.lexicographicalComparator(); 51 | 52 | ByteBuffer a = make("0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", 53 | "0000 0000", "0000 0000"); 54 | ByteBuffer b = make("1000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", 55 | "0000 0000", "0000 0000"); 56 | 57 | assertTrue(comparator.compare(a, a) == 0); 58 | assertTrue(comparator.compare(b, b) == 0); 59 | assertTrue(comparator.compare(a, b) < 0); 60 | assertTrue(comparator.compare(b, a) > 0); 61 | } 62 | 63 | @Test 64 | public void testUnsafeComparatorWithLongAndRemaining() { 65 | Comparator comparator = UnsignedByteBuffer.lexicographicalComparator(); 66 | 67 | ByteBuffer a = make("0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", 68 | "0000 0000", "0000 0000"); 69 | ByteBuffer b = make("0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", "0000 0000", 70 | "0000 0000", "1000 0000"); 71 | 72 | assertTrue(comparator.compare(a, a) == 0); 73 | assertTrue(comparator.compare(b, b) == 0); 74 | assertTrue(comparator.compare(a, b) < 0); 75 | assertTrue(comparator.compare(b, a) > 0); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /atomlayer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | atomlayer 6 | pom 7 | 8 | Atom Layer 9 | 10 | 11 | core 12 | baggagecontext-impl 13 | 14 | 15 | 16 | brown.tracingplane 17 | tracingplane-project 18 | 1.0 19 | 20 | 21 | 22 | ${basedir}/.. 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /baggagecontext/api/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /baggagecontext/api/README.md: -------------------------------------------------------------------------------- 1 | # Tracing Plane - Core 2 | 3 | Defines two core Tracing Plane interfaces - `BaggageContext` and `BaggageProvider`. 4 | 5 | A `BaggageContext` supports several fundamental propagation operations, that are implemented by its `BaggageProvider`. They are: 6 | 7 | * `newInstance()` -- creates a new, empty `BaggageContext`. Depending on the `BaggageProvider`, it may choose to represent empty `BaggageContext` instances using null 8 | * `branch(BaggageContext)` -- creates a duplicate `BaggageContext`. Typically this just creates a copy. Changes made to the branched `BaggageContext` will not be visible in the original, and vice versa. 9 | * `join(BaggageContext, BaggageContext)` -- merges the values of two `BaggageContext` instances. If there is no conflicting data within the `BaggageContexts`, this resembles a union of their contents. However, if they both contain, e.g., values mapped to the same key, and those values differ, then the `BaggageProvider` must implement some sort of conflict resolution. 10 | * `serialize(BaggageContext)` -- serializes the `BaggageContext` to a binary representation. For a string-based representation, either use a `BaggageProvider`-specified representation, or `base64` encode the binary representation 11 | * `deserialize(BaggageContext)` -- corresponding deserialization method 12 | * `trim` -- trim is a special operation, that is exposed as `serialize(BaggageContext, maximumSerializedLength)`. `BaggageProvider` is expected to provide a serialization method that drops data if it exceeds a certain length threshold. 13 | 14 | The above methods only pertain to propagating `BaggageContext`. There are no methods for accessing `BaggageContext` data or values. The `BaggageProvider` is responsible for providing accessor interfaces. 15 | 16 | With respect to the Tracing Plane, we provide a concise, efficient implementation of all of these methods using a representation based on *atoms*. -------------------------------------------------------------------------------- /baggagecontext/api/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggagecontext-api 6 | jar 7 | 8 | Baggage Context - API 9 | 10 | 11 | brown.tracingplane 12 | baggagecontext 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /baggagecontext/api/src/main/java/brown/tracingplane/BaggageContext.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | /** 4 | *

5 | * A {@link BaggageContext} is an opaque context object belonging to an execution. Baggage contexts are propagated 6 | * alongside requests as they execute -- they should be passed to new threads, included with work items (e.g., 7 | * {@link java.lang.Runnable}, {@link java.util.concurrent.Callable}, etc.), serialized in network headers, and so on. 8 | *

9 | * 10 | *

11 | * {@link BaggageContext} objects have no direct methods for manipulating contexts or accessing data that they carry. 12 | * This is because, in the common case, a {@link BaggageContext} is typically empty, and an empty context is typically 13 | * implemented using null values. 14 | *

15 | * 16 | *

17 | * To propagate {@link BaggageContext} objects, call {@link BaggageProvider} methods such as 18 | * {@link BaggageProvider#branch(BaggageContext)}, {@link BaggageProvider#serialize(BaggageContext)}, etc. 19 | *

20 | */ 21 | public interface BaggageContext { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /baggagecontext/api/src/main/java/brown/tracingplane/BaggageProviderFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | /** 4 | *

5 | * Factory for {@link BaggageProvider} instances; primarily used to configure the {@link BaggageProvider} used by the 6 | * {@link Baggage} static API. 7 | *

8 | * 9 | *

10 | * {@link BaggageProviderFactory} is expected to have a no-arg constructor so that it can be instantiated by reflection. 11 | *

12 | */ 13 | public interface BaggageProviderFactory { 14 | 15 | /** 16 | * Instantiate the {@link BaggageProvider} that this factory provides. 17 | * 18 | * @return a {@link BaggageProvider} instance 19 | */ 20 | public BaggageProvider provider(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /baggagecontext/api/src/main/java/brown/tracingplane/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * Provides the main {@link BaggageContext} and {@link BaggageProvider} interfaces of the Tracing Plane 4 | *

5 | * 6 | *

7 | * At a high level, {@link BaggageContext} instances exist at the granularity of requests (or tasks, jobs, etc). The 8 | * purpose is to propagate a {@link BaggageContext} alongside each request while it executes. {@link BaggageContext}s 9 | * carry user-defined or tracing-tool defined data. 10 | *

11 | * 12 | *

13 | * {@link BaggageContext} instances should follow requests in a fine-grained manner. For example, if a request splits 14 | * off into multiple concurrent execution branches, then each branch of execution should receive its its own 15 | * {@link BaggageContext} instance, created by calling {@link BaggageProvider#branch(BaggageContext)} at the time the 16 | * request splits. 17 | *

18 | * 19 | *

20 | * Likewise, if multiple concurrent branches merge, or if some task is dependent upon multiple predecessors completing, 21 | * then {@link BaggageContext} instances can be merged using 22 | * {@link BaggageProvider#join(BaggageContext, BaggageContext)}. 23 | *

24 | * 25 | *

26 | * The Tracing Plane provides several {@link BaggageContext} implementations, the main implementation being 27 | * {@link brown.tracingplane.impl.BDLContext} in the {@link brown.tracingplane.bdl} package. 28 | *

29 | */ 30 | package brown.tracingplane; 31 | -------------------------------------------------------------------------------- /baggagecontext/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggagecontext 6 | pom 7 | 8 | Baggage Context 9 | 10 | 11 | api 12 | staticapi 13 | transitlayer 14 | 15 | 16 | 17 | brown.tracingplane 18 | tracingplane-project 19 | 1.0 20 | 21 | 22 | 23 | ${basedir}/.. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/README.md: -------------------------------------------------------------------------------- 1 | # Tracing Plane - Static API 2 | 3 | The Tracing Plane provides a static API `brown.tracingplane.Baggage` for manipulating `BaggageContext` instances. This static API is the main entry point for manipulating contexts directly. Supported methods are: 4 | 5 | * `newInstance()` -- creates a new, empty `BaggageContext`; possibly a `null` value 6 | * `branch(BaggageContext)` -- creates a duplicate `BaggageContext`. Typically this just creates a copy. Changes made to the branched `BaggageContext` will not be visible in the original, and vice versa. 7 | * `join(BaggageContext, BaggageContext)` -- merges the values of two `BaggageContext` instances. If there is no conflicting data within the `BaggageContexts`, this resembles a union of their contents. However, if they both contain, e.g., values mapped to the same key, and those values differ, then the `BaggageProvider` must implement some sort of conflict resolution. 8 | * `serialize(BaggageContext)` -- serializes the `BaggageContext` to a binary representation. For a string-based representation, either use a `BaggageProvider`-specified representation, or `base64` encode the binary representation 9 | * `deserialize(BaggageContext)` -- corresponding deserialization method 10 | * `trim` -- trim is a special operation, that is exposed as `serialize(BaggageContext, maximumSerializedLength)`. `BaggageProvider` is expected to provide a serialization method that drops data if it exceeds a certain length threshold. 11 | 12 | Example usage in code is, for example, to pass a `BaggageContext` to a new thread: 13 | 14 | BaggageContext currentContext; 15 | MyThread newThread = new MyThread(Baggage.branch(currentContext)); 16 | 17 | Or to serialize a context for inclusion in network calls: 18 | 19 | BaggageContext currentContext; 20 | out.write(Baggage.serialize(currentContext)); 21 | 22 | The Tracing Plane also provides an `ActiveBaggage` API that mirrors these method calls. 23 | 24 | Use of the `Baggage` static API depends on a `BaggageProvider` being configured. Typically, this is done automatically by the Tracing Plane distribution that you use. If this is not the case, or if you wish to override the `BaggageProvider` implementation being used, then you can set the `baggage.provider` property to the `BaggageProviderFactory` of your choice, e.g., 25 | 26 | -Dbaggage.provider=brown.tracingplane.impl.NoOpBaggageContextProviderFactory 27 | 28 | or in the typesafe `application.conf`: 29 | 30 | baggage.provider = "brown.tracingplane.impl.NoOpBaggageContextProviderFactory" -------------------------------------------------------------------------------- /baggagecontext/staticapi/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggagecontext-staticapi 6 | jar 7 | 8 | Baggage Context - Static API 9 | 10 | 11 | brown.tracingplane 12 | baggagecontext 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggagecontext-api 24 | ${project.version} 25 | 26 | 27 | org.slf4j 28 | slf4j-api 29 | 30 | 31 | org.slf4j 32 | slf4j-log4j12 33 | 34 | 35 | com.typesafe 36 | config 37 | 38 | 39 | junit 40 | junit 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/src/main/java/brown/tracingplane/impl/NoOpBaggageContextProvider.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | import brown.tracingplane.BaggageContext; 5 | import brown.tracingplane.BaggageProvider; 6 | 7 | /** 8 | * A {@link BaggageProvider} implementation that always just returns null. 9 | */ 10 | public class NoOpBaggageContextProvider implements BaggageProvider { 11 | 12 | @Override 13 | public boolean isValid(BaggageContext baggage) { 14 | return baggage == null; 15 | } 16 | 17 | @Override 18 | public BaggageContext newInstance() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public void discard(BaggageContext baggage) {} 24 | 25 | @Override 26 | public BaggageContext branch(BaggageContext from) { 27 | return null; 28 | } 29 | 30 | @Override 31 | public BaggageContext join(BaggageContext left, BaggageContext right) { 32 | return null; 33 | } 34 | 35 | @Override 36 | public BaggageContext deserialize(byte[] serialized, int offset, int length) { 37 | return null; 38 | } 39 | 40 | @Override 41 | public BaggageContext deserialize(ByteBuffer buf) { 42 | return null; 43 | } 44 | 45 | @Override 46 | public byte[] serialize(BaggageContext baggage) { 47 | return null; 48 | } 49 | 50 | @Override 51 | public byte[] serialize(BaggageContext baggage, int maximumSerializedSize) { 52 | return null; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/src/main/java/brown/tracingplane/impl/NoOpBaggageContextProviderFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.BaggageContext; 4 | import brown.tracingplane.BaggageProvider; 5 | import brown.tracingplane.BaggageProviderFactory; 6 | 7 | /** 8 | * A {@link BaggageProvider} implementation that always just returns null. 9 | */ 10 | public class NoOpBaggageContextProviderFactory implements BaggageProviderFactory { 11 | 12 | @Override 13 | public BaggageProvider provider() { 14 | return new NoOpBaggageContextProvider(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/src/main/java/brown/tracingplane/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * Implementations of {@link BaggageContext} at several different points in the Tracing Plane. 4 | *

5 | * 6 | *

7 | * {@link AtomContext} is the most lightweight atom-based context, which provides no accessor or convenience methods for 8 | * manipulating data. {@link AtomContext} is purely for propagation (e.g., forwarding baggage contexts that you received 9 | * from other network calls). 10 | *

11 | * 12 | *

13 | * {@link NestedBaggageContext} extends the Atom Context and implements the Baggage Protocol, which gives nested data 14 | * structures. 15 | *

16 | * 17 | *

18 | * {@link BDLContext} is the full-featured baggage context, which provides interpretations for different data types 19 | * using atoms. 20 | *

21 | * 22 | */ 23 | package brown.tracingplane.impl; 24 | -------------------------------------------------------------------------------- /baggagecontext/staticapi/src/test/java/brown/tracingplane/impl/TestNoOpBaggageContextProvider.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertNull; 6 | import static org.junit.Assert.assertTrue; 7 | import org.junit.Test; 8 | import brown.tracingplane.BaggageContext; 9 | import brown.tracingplane.BaggageProvider; 10 | import brown.tracingplane.BaggageProviderFactory; 11 | 12 | public class TestNoOpBaggageContextProvider { 13 | 14 | @Test 15 | public void testNoOpBaggageContextProviderFactory() { 16 | BaggageProviderFactory factory = new NoOpBaggageContextProviderFactory(); 17 | 18 | BaggageProvider provider = factory.provider(); 19 | assertNotNull(provider); 20 | assertTrue(provider instanceof NoOpBaggageContextProvider); 21 | } 22 | 23 | @Test 24 | public void testNoOpBaggageContextProvider() { 25 | BaggageProvider provider = new NoOpBaggageContextProvider(); 26 | 27 | assertNull(provider.newInstance()); 28 | assertNull(provider.branch(null)); 29 | assertNull(provider.join(null, null)); 30 | assertNull(provider.serialize(null)); 31 | assertNull(provider.serialize(null, 0)); 32 | assertNull(provider.deserialize(null)); 33 | assertNull(provider.deserialize(null, 0, 0)); 34 | assertTrue(provider.isValid(null)); 35 | 36 | BaggageContext invalidContext = new BaggageContext() {}; 37 | assertFalse(provider.isValid(invalidContext)); 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /baggagecontext/transitlayer/README.md: -------------------------------------------------------------------------------- 1 | # TracingPlane:BaggageContext/TransitLayer 2 | 3 | This package provides the following: 4 | 5 | * The core interfaces for the Tracing Plane's `TransitLayer` -- to enhance the existing `BaggageContext` and `Baggage` interfaces that exist in `BaggageContext/API` and `BaggageContext/StaticAPI`. 6 | * The out-of-the-box `TransitLayer` implementation, which is a NoOp and does nothing -- method calls are essentially ignored 7 | * A `TransitLayer` implementation based on thread-local variables. This is the recommended context propagation library to use with the tracing plane. It is the default `TransitLayer` implementation in the Tracing Plane distribution jars. 8 | 9 | ## Transit Layer 10 | 11 | The Tracing Plane provides an out-of-the-box context propagation library called the "Transit Layer". The Transit Layer uses thread-local storage to store `BaggageContext` instances for threads, and provides a static API in `brown.tracingplane.ActiveBaggage` that invokes transit layer methods. `ActiveBaggage` provides methods as follows: 12 | 13 | * `set(BaggageContext)` -- set the active `BaggageContext` for this thread 14 | * `get()` -- get the active `BaggageContext` for this thread 15 | * `take()` -- remove and return the active `BaggageContext` for this thread 16 | * `takeBytes()` -- remove, return, and serialize the active `BaggageContext` for this thread 17 | * `discard()` -- discard the active `BaggageContext` for this thread 18 | 19 | In addition to methods for manipulating the active baggage, the Transit Layer and `ActiveBaggage` interface provides methods mirroring those in the `Baggage` and `BaggageProvider` interfaces, to implicitly manipulate the current context: 20 | 21 | * `branch()` -- creates and returns a duplicate of the currently active `BaggageContext`. 22 | * `join(BaggageContext)` -- merges the values of some `BaggageContext` object into the active context. 23 | 24 | The Transit Layer is configurable, and alternative implementations can be used other than the out-of-the-box thread-local implementation. To provide a different implementation, simply implement the `TransitLayer` and `TransitLayerFactory` interfaces, then configure the factory class using the `baggage.transit` property, e.g.: 25 | 26 | -Dbaggage.transit=brown.tracingplane.impl.ThreadLocalTransitLayerFactory 27 | 28 | or, using typesafe config `application.conf`: 29 | 30 | baggage.transit = "brown.tracingplane.impl.ThreadLocalTransitLayerFactory" -------------------------------------------------------------------------------- /baggagecontext/transitlayer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | transitlayer 6 | jar 7 | 8 | Baggage Context - Transit Layer Impl 9 | 10 | 11 | brown.tracingplane 12 | baggagecontext 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggagecontext-staticapi 24 | ${project.version} 25 | 26 | 27 | org.slf4j 28 | slf4j-api 29 | 30 | 31 | org.slf4j 32 | slf4j-log4j12 33 | 34 | 35 | com.typesafe 36 | config 37 | 38 | 39 | junit 40 | junit 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/main/java/brown/tracingplane/DefaultTransitLayer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import com.typesafe.config.Config; 6 | import com.typesafe.config.ConfigException; 7 | import com.typesafe.config.ConfigFactory; 8 | import brown.tracingplane.impl.NoOpTransitLayerFactory; 9 | import brown.tracingplane.impl.ThreadLocalTransitLayer; 10 | 11 | /** 12 | *

13 | * Loads the {@link TransitLayerFactory} specified by baggage.transit using reflection. 14 | *

15 | */ 16 | public class DefaultTransitLayer { 17 | 18 | private static final Logger log = LoggerFactory.getLogger(DefaultTransitLayer.class); 19 | 20 | private final TransitLayerFactory factory; 21 | private final TransitLayer transitlayer; 22 | 23 | /** Not instantiable */ 24 | private DefaultTransitLayer() { 25 | Config config = ConfigFactory.load(); 26 | 27 | TransitLayerFactory factory = null; 28 | if (!config.hasPath("baggage.transit")) { 29 | log.warn("No TransitLayerFactory has been configured using baggage.transit -- baggage propagation using the ActiveBaggage interface will be disabled"); 30 | } else { 31 | try { 32 | String transitLayerClass = config.getString("baggage.transit"); 33 | 34 | try { 35 | Object instantiated = Class.forName(transitLayerClass).newInstance(); 36 | 37 | try { 38 | factory = (TransitLayerFactory) instantiated; 39 | } catch (ClassCastException e) { 40 | log.error("The configured baggage.transit should be an instance of TransitLayerFactory; found " + 41 | instantiated.getClass().getName()); 42 | } 43 | } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { 44 | log.error("Unable to instantiate TransitLayerFactory specified by baggage.transit " + 45 | transitLayerClass, e); 46 | } 47 | 48 | } catch (ConfigException.WrongType e) { 49 | Object v = config.getAnyRef("baggage.transit"); 50 | log.error("Invalid baggage.transit has been configured -- baggage propagation using the ActiveBaggage interface will be disabled. Expected a string for baggage.provider, found " + 51 | v.getClass().getName() + ": " + v); 52 | } 53 | } 54 | 55 | if (factory == null) { 56 | this.factory = new NoOpTransitLayerFactory(); 57 | this.transitlayer = this.factory.transitlayer(); 58 | } else { 59 | this.factory = factory; 60 | this.transitlayer = this.factory.transitlayer(); 61 | } 62 | } 63 | 64 | private static DefaultTransitLayer instance = null; 65 | 66 | private static DefaultTransitLayer instance() { 67 | if (instance == null) { 68 | synchronized (DefaultTransitLayer.class) { 69 | if (instance == null) { 70 | instance = new DefaultTransitLayer(); 71 | } 72 | } 73 | } 74 | return instance; 75 | } 76 | 77 | /** 78 | * @return the configured {@link TransitLayer} instance. The default transit layer can be set using 79 | * -Dbaggage.transit. If no instance has been configured, this method will return a 80 | * {@link ThreadLocalTransitLayer} that uses simple thread-local storage to store baggage contexts. 81 | */ 82 | public static TransitLayer get() { 83 | return instance().transitlayer; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/main/java/brown/tracingplane/TransitLayerFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | /** 4 | *

5 | * Factory for {@link TransitLayer} instances; primarily used to configure the {@link TransitLayer} used by the 6 | * {@link ActiveBaggage} static API. 7 | *

8 | * 9 | *

10 | * {@link TransitLayerFactory} is expected to have a no-arg constructor so that it can be instantiated by reflection. 11 | *

12 | */ 13 | public interface TransitLayerFactory { 14 | 15 | /** 16 | * Instantiate the {@link TransitLayer} implementation that this factory provides. 17 | * 18 | * @return a {@link TransitLayer} instance 19 | */ 20 | public TransitLayer transitlayer(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/main/java/brown/tracingplane/impl/NoOpTransitLayer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | import brown.tracingplane.ActiveBaggage; 5 | import brown.tracingplane.BaggageContext; 6 | import brown.tracingplane.TransitLayer; 7 | 8 | /** 9 | *

10 | * A {@link TransitLayer} that does nothing. This is the default {@link TransitLayer} implementation that will be used 11 | * in lieu of anything else. If this is the {@link TransitLayer} implementation used, the effect is that any calls to 12 | * the {@link ActiveBaggage} interface will find that there is no active baggage. 13 | *

14 | * 15 | *

16 | * {@link NoOpTransitLayer} is typically going to be used at instrumentation time, prior to binding to a particular 17 | * implementation. 18 | *

19 | * 20 | *

21 | * If you intend to use a different instrumentation library altogether to propagate contexts (e.g., OpenTracing), then 22 | * you would either: 23 | *

    24 | *
  • Implement a {@link TransitLayer} that opaquely proxies to your other instrumentation library
  • 25 | *
  • Not use this library at all
  • 26 | *
27 | *

28 | */ 29 | public class NoOpTransitLayer implements TransitLayer { 30 | 31 | @Override 32 | public void discard() {} 33 | 34 | @Override 35 | public BaggageContext branch() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public byte[] branchBytes() { 41 | return null; 42 | } 43 | 44 | @Override 45 | public void join(BaggageContext otherContext) {} 46 | 47 | @Override 48 | public void join(ByteBuffer serializedContext) {} 49 | 50 | @Override 51 | public void join(byte[] serialized, int offset, int length) {} 52 | 53 | @Override 54 | public void set(BaggageContext baggage) {} 55 | 56 | @Override 57 | public void set(ByteBuffer serializedContext) {} 58 | 59 | @Override 60 | public void set(byte[] serialized, int offset, int length) {} 61 | 62 | @Override 63 | public BaggageContext take() { 64 | return null; 65 | } 66 | 67 | @Override 68 | public byte[] takeBytes() { 69 | return null; 70 | } 71 | 72 | @Override 73 | public BaggageContext peek() { 74 | return null; 75 | } 76 | 77 | @Override 78 | public void update(BaggageContext baggage) {} 79 | 80 | } 81 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/main/java/brown/tracingplane/impl/NoOpTransitLayerFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.ActiveBaggage; 4 | import brown.tracingplane.TransitLayer; 5 | import brown.tracingplane.TransitLayerFactory; 6 | 7 | /** 8 | *

9 | * A {@link TransitLayer} that does nothing. This is the default {@link TransitLayer} implementation that will be used 10 | * if none is configured. If this is the {@link TransitLayer} implementation used, the effect is that any calls to the 11 | * {@link ActiveBaggage} interface will find that there is no active baggage. 12 | *

13 | */ 14 | public class NoOpTransitLayerFactory implements TransitLayerFactory { 15 | 16 | @Override 17 | public TransitLayer transitlayer() { 18 | return new NoOpTransitLayer(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/main/java/brown/tracingplane/impl/ThreadLocalTransitLayerFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.DefaultBaggageProvider; 4 | import brown.tracingplane.TransitLayer; 5 | import brown.tracingplane.TransitLayerFactory; 6 | 7 | /** 8 | *

9 | * The {@link TransitLayerFactory} that creates {@link ThreadLocalTransitLayer} instances. If you need to manually 10 | * configure the {@link TransitLayer}, you would set baggage.transit to be this class, e.g.: 11 | * 12 | *

13 |  * -Dbaggage.transit=brown.tracingplane.impl.ThreadLocalTransitLayerFactory
14 |  * 
15 | * 16 | * or in the typesafe config application.conf: 17 | * 18 | *
19 |  * baggage.transit = "brown.tracingplane.impl.ThreadLocalTransitLayerFactory"
20 |  * 
21 | *

22 | */ 23 | public class ThreadLocalTransitLayerFactory implements TransitLayerFactory { 24 | 25 | @Override 26 | public TransitLayer transitlayer() { 27 | return new ThreadLocalTransitLayer(DefaultBaggageProvider.getWrapped()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/test/java/brown/tracingplane/impl/TestNoOpTransitLayer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | public class TestNoOpTransitLayer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /baggagecontext/transitlayer/src/test/java/brown/tracingplane/impl/TestThreadLocalTransitLayer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | public class TestThreadLocalTransitLayer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /baggageprotocol/baggagecontext-impl/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /baggageprotocol/baggagecontext-impl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggageprotocol-baggagecontext 6 | jar 7 | 8 | Baggage Protocol - BaggageContext Impl 9 | 10 | 11 | brown.tracingplane 12 | baggageprotocol 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggagecontext-api 24 | ${project.version} 25 | 26 | 27 | brown.tracingplane 28 | baggageprotocol-core 29 | ${project.version} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /baggageprotocol/baggagecontext-impl/src/main/java/brown/tracingplane/impl/NestedBaggageContext.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.TreeMap; 8 | import brown.tracingplane.BaggageContext; 9 | import brown.tracingplane.atomlayer.ByteBuffers; 10 | import brown.tracingplane.atomlayer.Lexicographic; 11 | import brown.tracingplane.baggageprotocol.BagKey; 12 | import brown.tracingplane.baggageprotocol.BaggageReader; 13 | import brown.tracingplane.baggageprotocol.BaggageWriter; 14 | 15 | /** 16 | *

17 | * An implementation of {@link BaggageContext} that interprets atoms using the baggage protocol, which specifies a data 18 | * layout for nested bags. 19 | *

20 | */ 21 | public class NestedBaggageContext implements BaggageContext { 22 | 23 | public boolean didOverflow = false; 24 | public List dataAtoms = new ArrayList<>(); 25 | public Map children = new TreeMap<>(); 26 | 27 | static NestedBaggageContext parse(BaggageReader reader) { 28 | if (!reader.hasNext()) { 29 | return null; 30 | } 31 | NestedBaggageContext bag = new NestedBaggageContext(); 32 | while (reader.hasData()) { 33 | bag.dataAtoms.add(reader.nextData()); 34 | } 35 | if (reader.didOverflow()) { 36 | bag.didOverflow = true; 37 | } 38 | while (reader.hasChild()) { 39 | BagKey childKey = reader.enter(); 40 | NestedBaggageContext childBag = parse(reader); 41 | if (childBag != null) { 42 | bag.children.put(childKey, childBag); 43 | } 44 | reader.exit(); 45 | } 46 | return bag; 47 | } 48 | 49 | void serialize(BaggageWriter writer) { 50 | writer.didOverflowHere(didOverflow); 51 | for (ByteBuffer atom : dataAtoms) { 52 | ByteBuffer newAtom = writer.newDataAtom(atom.remaining()); 53 | ByteBuffers.copyTo(atom, newAtom); 54 | } 55 | for (BagKey childKey : children.keySet()) { 56 | writer.enter(childKey); 57 | children.get(childKey).serialize(writer); 58 | writer.exit(); 59 | } 60 | } 61 | 62 | public NestedBaggageContext branch() { 63 | NestedBaggageContext copy = new NestedBaggageContext(); 64 | copy.didOverflow = didOverflow; 65 | copy.dataAtoms.addAll(dataAtoms); 66 | for (BagKey childKey : children.keySet()) { 67 | copy.children.put(childKey, children.get(childKey).branch()); 68 | } 69 | return copy; 70 | } 71 | 72 | public void mergeWith(NestedBaggageContext right) { 73 | if (right == null) { 74 | return; 75 | } 76 | 77 | this.didOverflow |= right.didOverflow; 78 | 79 | if (this.dataAtoms == null) { 80 | this.dataAtoms = right.dataAtoms; 81 | } else if (right.dataAtoms != null) { 82 | this.dataAtoms = Lexicographic.merge(this.dataAtoms, right.dataAtoms); 83 | } 84 | 85 | if (this.children == null) { 86 | this.children = right.children; 87 | } else if (right.children != null) { 88 | for (BagKey childKey : right.children.keySet()) { 89 | NestedBaggageContext leftChild = this.children.get(childKey); 90 | NestedBaggageContext rightChild = right.children.get(childKey); 91 | if (leftChild != null) { 92 | leftChild.mergeWith(rightChild); 93 | } else { 94 | this.children.put(childKey, rightChild); 95 | } 96 | } 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /baggageprotocol/baggagecontext-impl/src/main/java/brown/tracingplane/impl/NestedBaggageContextProvider.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.List; 5 | import brown.tracingplane.BaggageContext; 6 | import brown.tracingplane.BaggageProvider; 7 | import brown.tracingplane.atomlayer.AtomLayerSerialization; 8 | import brown.tracingplane.baggageprotocol.BaggageReader; 9 | import brown.tracingplane.baggageprotocol.BaggageWriter; 10 | 11 | /** 12 | *

13 | * {@link BaggageProvider} for {@link NestedBaggageContext}, which extends {@link AtomContext} to interpret atoms as 14 | * nested data structures. 15 | *

16 | */ 17 | public class NestedBaggageContextProvider implements BaggageProvider { 18 | 19 | @Override 20 | public boolean isValid(BaggageContext baggage) { 21 | return baggage == null || baggage instanceof NestedBaggageContext; 22 | } 23 | 24 | @Override 25 | public NestedBaggageContext newInstance() { 26 | return null; 27 | } 28 | 29 | @Override 30 | public void discard(NestedBaggageContext baggage) {} 31 | 32 | @Override 33 | public NestedBaggageContext branch(NestedBaggageContext from) { 34 | return from == null ? null : from.branch(); 35 | } 36 | 37 | @Override 38 | public NestedBaggageContext join(NestedBaggageContext left, NestedBaggageContext right) { 39 | if (left == null) { 40 | return right; 41 | } else { 42 | left.mergeWith(right); 43 | return left; 44 | } 45 | } 46 | 47 | @Override 48 | public NestedBaggageContext deserialize(byte[] serialized, int offset, int length) { 49 | List atoms = AtomLayerSerialization.deserialize(serialized, offset, length); 50 | return NestedBaggageContext.parse(BaggageReader.create(atoms)); 51 | } 52 | 53 | @Override 54 | public NestedBaggageContext deserialize(ByteBuffer buf) { 55 | List atoms = AtomLayerSerialization.deserialize(buf); 56 | return NestedBaggageContext.parse(BaggageReader.create(atoms)); 57 | } 58 | 59 | @Override 60 | public byte[] serialize(NestedBaggageContext baggage) { 61 | if (baggage == null) { 62 | return null; 63 | } 64 | BaggageWriter writer = BaggageWriter.create(); 65 | baggage.serialize(writer); 66 | List atoms = writer.atoms(); 67 | return AtomLayerSerialization.serialize(atoms); 68 | } 69 | 70 | @Override 71 | public byte[] serialize(NestedBaggageContext baggage, int maximumSerializedSize) { 72 | if (baggage == null) { 73 | return null; 74 | } 75 | BaggageWriter writer = BaggageWriter.create(); 76 | baggage.serialize(writer); 77 | List atoms = writer.atoms(); 78 | return AtomLayerSerialization.serialize(atoms, maximumSerializedSize); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /baggageprotocol/baggagecontext-impl/src/main/java/brown/tracingplane/impl/NestedBaggageContextProviderFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.BaggageContext; 4 | import brown.tracingplane.BaggageProvider; 5 | import brown.tracingplane.BaggageProviderFactory; 6 | 7 | /** 8 | * {@link BaggageProviderFactory} for {@link NestedBaggageContextProvider} 9 | */ 10 | public class NestedBaggageContextProviderFactory implements BaggageProviderFactory { 11 | 12 | @Override 13 | public BaggageProvider provider() { 14 | return new NestedBaggageContextProvider(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /baggageprotocol/core/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /baggageprotocol/core/README.md: -------------------------------------------------------------------------------- 1 | # Tracing Plane - Baggage Protocol 2 | 3 | The Baggage Protocol defines interfaces for nested data structures, along with an atom-based encoding scheme for the nested data structures. 4 | 5 | The encoding scheme is such that the Atom Layer's lexicographic merge behaves consistently with an equivalent object-level merge. -------------------------------------------------------------------------------- /baggageprotocol/core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggageprotocol-core 6 | jar 7 | 8 | Baggage Protocol - Core 9 | 10 | 11 | brown.tracingplane 12 | baggageprotocol 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggagecontext-api 24 | ${project.version} 25 | 26 | 27 | brown.tracingplane 28 | atomlayer-core 29 | ${project.version} 30 | 31 | 32 | junit 33 | junit 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/BagOptions.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | /** 4 | *

5 | * The only additional option that we propagate is the merge behavior. We do not propagate serialize or branch 6 | * behaviors, as follows: 7 | *

8 | * 9 | *
    10 | *
  • The main use case for specifying branch and serialize behaviors is to handle 'brittle' fields. The default 11 | * propagation behavior is `ignore and propagate`; however, you might want to override this to drop data in some 12 | * scenarios. For example, you might have a vector clock style component id in the baggage and could want to ensure that 13 | * only one side of the branch retains the ID.
  • 14 | *
  • Because of this it could be argued that the baggage layer could have some options for specifying logic for when 15 | * baggage operations (branch, join, serialize) occur.
  • 16 | *
  • The reason for implementing logic in the baggage layer is for when data traverses other processes that are 17 | * baggage compliant, but lack knowledge of the semantics of specific fields of the baggage
  • 18 | *
  • However, when the baggage leaves the current process, it might traverse atom-compliant-only processes (ie, 19 | * non-baggage-compliant) that naively copy the data (because they adhere to `ignore and propagate`. This is 20 | * unavoidable. So we cannot provide guarantees for brittle fields outside of a process.
  • 21 | *
  • Within a process, if the process knows how to add one of these brittle fields to the baggage, then it is implied 22 | * that the process knows the semantics of that field. Thus, the process also has control of when the baggage will 23 | * branch, join, and serialize within this process. This means it can interpose on the baggage via callbacks
  • 24 | *
  • As a result, we argue that branch and serialize options are unnecessary and can be handled by callbacks
  • 25 | *
26 | */ 27 | public class BagOptions implements Comparable { 28 | 29 | private static final BagOptions[] values = 30 | { new BagOptions(MergeBehavior.TakeAll), new BagOptions(MergeBehavior.TakeFirst) }; 31 | public static final BagOptions defaultOptions = values[0]; 32 | 33 | public static enum MergeBehavior { 34 | TakeAll, TakeFirst; 35 | } 36 | 37 | public final MergeBehavior merge; 38 | 39 | private BagOptions(MergeBehavior merge) { 40 | this.merge = merge; 41 | } 42 | 43 | public static BagOptions defaultOptions() { 44 | return defaultOptions; 45 | } 46 | 47 | public static BagOptions create(MergeBehavior mergeBehavior) { 48 | return values[mergeBehavior.ordinal()]; 49 | } 50 | 51 | public boolean isDefault() { 52 | return this == defaultOptions; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return String.format("[BagOptions Merge=%s]", merge.name()); 58 | } 59 | 60 | @Override 61 | public int compareTo(BagOptions o) { 62 | return merge.compareTo(o.merge); 63 | } 64 | 65 | public static BagOptions[] values() { 66 | return values; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/BaggageLayerException.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import brown.tracingplane.atomlayer.AtomLayerException; 4 | 5 | public class BaggageLayerException extends Exception { 6 | 7 | private static final long serialVersionUID = -7124041854080833387L; 8 | 9 | public BaggageLayerException(String message) { 10 | super(message); 11 | } 12 | 13 | public BaggageLayerException(String message, AtomLayerException e) { 14 | super(message, e); 15 | } 16 | 17 | public static class BaggageLayerRuntimeException extends RuntimeException { 18 | 19 | private static final long serialVersionUID = 2072227973209173448L; 20 | 21 | public BaggageLayerRuntimeException(String message) { 22 | super(message); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/BaggageProtocol.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import java.nio.ByteBuffer; 4 | import brown.tracingplane.atomlayer.AtomLayerOverflow; 5 | import brown.tracingplane.baggageprotocol.AtomPrefixes.DataPrefix; 6 | 7 | public class BaggageProtocol { 8 | 9 | public static final ByteBuffer TRIM_MARKER = ByteBuffer.wrap(new byte[] { DataPrefix.prefix }); 10 | public static final ByteBuffer OVERFLOW_MARKER = AtomLayerOverflow.OVERFLOW_MARKER; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/ElementReader.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Iterator-like interface for reading data atoms 7 | */ 8 | public interface ElementReader { 9 | public boolean hasData(); 10 | 11 | public ByteBuffer nextData(); 12 | 13 | public void dropData(); 14 | 15 | public void keepData(); 16 | } 17 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/ElementWriter.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Iterator-like interface for writing atoms. 7 | */ 8 | public interface ElementWriter { 9 | 10 | public ByteBuffer newDataAtom(int expectedSize); 11 | 12 | public BaggageWriter writeBytes(ByteBuffer buf); 13 | 14 | public void flush(); 15 | 16 | public void sortData(); 17 | 18 | } -------------------------------------------------------------------------------- /baggageprotocol/core/src/main/java/brown/tracingplane/baggageprotocol/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * Defines an encoding scheme for nested data structures using atoms. 4 | *

5 | * 6 | *

7 | * The Baggage Protocol reads and writes {@link BaggageContext}s with a pre-order depth-first traversal. Starting from 8 | * the root of the tree, we first have data for that node, followed by child nodes. Child nodes can be addressed by 9 | * either statically defined indices, or by arbitrary-length key. 10 | *

11 | * 12 | *

13 | * The {@link BaggageReader} and {@link BaggageWriter} classes are used for reading and writing atoms for 14 | * {@link BaggageContext} instances. 15 | *

16 | * 17 | *

18 | * Details of the baggage protocol can be found on the project GitHub repository. 19 | *

20 | */ 21 | package brown.tracingplane.baggageprotocol; 22 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/test/java/brown/tracingplane/baggageprotocol/BaggageTestCase.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.fail; 6 | import java.nio.ByteBuffer; 7 | import java.util.List; 8 | import java.util.Random; 9 | import org.junit.Before; 10 | import org.junit.Rule; 11 | import org.junit.rules.ExpectedException; 12 | import com.google.common.collect.Lists; 13 | import brown.tracingplane.atomlayer.AtomLayerException; 14 | import brown.tracingplane.atomlayer.ByteBuffers; 15 | import brown.tracingplane.baggageprotocol.AtomPrefixes.DataPrefix; 16 | 17 | public abstract class BaggageTestCase { 18 | 19 | @Rule 20 | public final ExpectedException exception = ExpectedException.none(); 21 | 22 | final Random r = new Random(0); 23 | 24 | ByteBuffer randomBytes(int length) { 25 | byte[] bytes = new byte[length]; 26 | r.nextBytes(bytes); 27 | return ByteBuffer.wrap(bytes); 28 | } 29 | 30 | BagKey.Indexed indexed(int index) { 31 | return (BagKey.Indexed) BagKey.indexed(index); 32 | } 33 | 34 | ByteBuffer dataAtom(ByteBuffer payload) { 35 | ByteBuffer atom = ByteBuffer.allocate(payload.remaining() + 1); 36 | atom.put(DataPrefix.prefix); 37 | ByteBuffers.copyTo(payload, atom); 38 | atom.flip(); 39 | return atom; 40 | } 41 | 42 | ByteBuffer headerAtom(BagKey bagKey, int level) { 43 | return HeaderSerialization.serialize(bagKey, level); 44 | } 45 | 46 | List writeBag(BagKey key, ByteBuffer... contents) { 47 | BaggageWriter writer = BaggageWriter.create(); 48 | writer.enter(key); 49 | for (ByteBuffer content : contents) { 50 | ByteBuffers.copyTo(content, writer.newDataAtom(content.remaining())); 51 | } 52 | writer.exit(); 53 | return writer.atoms(); 54 | } 55 | 56 | List writeBag(BagKey a, BagKey b, ByteBuffer... contents) { 57 | BaggageWriter writer = BaggageWriter.create(); 58 | writer.enter(a); 59 | writer.enter(b); 60 | for (ByteBuffer content : contents) { 61 | ByteBuffers.copyTo(content, writer.newDataAtom(content.remaining())); 62 | } 63 | writer.exit(); 64 | writer.exit(); 65 | return writer.atoms(); 66 | } 67 | 68 | @Before 69 | public void setRandomSeed() throws Exception { 70 | r.setSeed(0); 71 | }; 72 | 73 | void assertOverflowPath(List overflowAtoms, BagKey... path) { 74 | assertOverflowPath(overflowAtoms, Lists. newArrayList(path)); 75 | } 76 | 77 | void assertOverflowPath(List overflowAtoms, List keys) { 78 | assertNotNull(overflowAtoms); 79 | assertEquals(keys.size() + 1, overflowAtoms.size()); 80 | for (int level = 0; level < keys.size(); level++) { 81 | BagKey key = keys.get(level); 82 | ByteBuffer atom = overflowAtoms.get(level); 83 | assertEquals(atom, HeaderSerialization.serialize(key, level)); 84 | try { 85 | assertEquals(key, HeaderSerialization.parse(atom)); 86 | } catch (AtomLayerException | BaggageLayerException e) { 87 | fail(e.getMessage()); 88 | e.printStackTrace(); 89 | } 90 | } 91 | assertEquals(BaggageProtocol.OVERFLOW_MARKER, overflowAtoms.get(keys.size())); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/test/java/brown/tracingplane/baggageprotocol/TestBagKey.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import java.nio.ByteBuffer; 5 | import org.junit.Test; 6 | import brown.tracingplane.atomlayer.Lexicographic; 7 | 8 | public class TestBagKey { 9 | 10 | @Test 11 | public void testBagKeyComparison() { 12 | int[] indicesToTest = 13 | { Integer.MIN_VALUE, Short.MIN_VALUE, -10, -3, -1, 0, 1, 3, 10, Short.MAX_VALUE, Integer.MAX_VALUE }; 14 | String[] keysToTest = { "", "a", "aaaaa", "hello", "hell", "boo" }; 15 | ByteBuffer[] bufs = new ByteBuffer[keysToTest.length]; 16 | for (int i = 0; i < keysToTest.length; i++) { 17 | bufs[i] = ByteBuffer.wrap(keysToTest[i].getBytes()); 18 | } 19 | 20 | for (int i : indicesToTest) { 21 | for (int j : indicesToTest) { 22 | assertEquals(Integer.compare(i, j), BagKey.indexed(i).compareTo(BagKey.indexed(j))); 23 | } 24 | for (String key : keysToTest) { 25 | assertEquals(-1, BagKey.indexed(i).compareTo(BagKey.named(key))); 26 | assertEquals(1, BagKey.named(key).compareTo(BagKey.indexed(i))); 27 | } 28 | for (ByteBuffer buf : bufs) { 29 | assertEquals(-1, BagKey.indexed(i).compareTo(BagKey.keyed(buf))); 30 | assertEquals(1, BagKey.keyed(buf).compareTo(BagKey.indexed(i))); 31 | } 32 | } 33 | 34 | for (ByteBuffer a : bufs) { 35 | for (ByteBuffer b : bufs) { 36 | assertEquals(Lexicographic.compare(a, b), BagKey.keyed(a).compareTo(BagKey.keyed(b))); 37 | } 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/test/java/brown/tracingplane/baggageprotocol/TestBaggage02_EmptyBaggage.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertNull; 6 | import org.junit.Test; 7 | import brown.tracingplane.baggageprotocol.BaggageLayerException.BaggageLayerRuntimeException; 8 | 9 | /** 10 | * Tests an empty baggage 11 | */ 12 | public class TestBaggage02_EmptyBaggage extends BaggageTestCase { 13 | 14 | private BaggageReader makeBaggage() { 15 | BaggageWriter writer = BaggageWriter.create(); 16 | return BaggageReader.create(writer.atoms()); 17 | } 18 | 19 | @Test 20 | public void testNextData() { 21 | BaggageReader reader = makeBaggage(); 22 | assertEquals(null, reader.nextData()); 23 | } 24 | 25 | @Test 26 | public void testHasNext() { 27 | BaggageReader reader = makeBaggage(); 28 | assertFalse(reader.hasNext()); 29 | } 30 | 31 | @Test 32 | public void testHasData() { 33 | BaggageReader reader = makeBaggage(); 34 | assertFalse(reader.hasData()); 35 | } 36 | 37 | @Test 38 | public void testHasChild() { 39 | BaggageReader reader = makeBaggage(); 40 | assertFalse(reader.hasChild()); 41 | } 42 | 43 | @Test 44 | public void testEnter1() { 45 | BaggageReader reader = makeBaggage(); 46 | assertNull(reader.enter()); 47 | } 48 | 49 | @Test 50 | public void testEnter2() { 51 | BaggageReader reader = makeBaggage(); 52 | assertFalse(reader.enter(indexed(3))); 53 | } 54 | 55 | @Test 56 | public void testExitThrowsException() { 57 | BaggageReader reader = makeBaggage(); 58 | exception.expect(BaggageLayerRuntimeException.class); 59 | reader.exit(); 60 | } 61 | 62 | @Test 63 | public void testNoUnprocessedData() { 64 | BaggageReader reader = makeBaggage(); 65 | reader.nextData(); 66 | assertNull(reader.unprocessedAtoms()); 67 | } 68 | 69 | @Test 70 | public void testDidNotOverflow() { 71 | BaggageReader reader = makeBaggage(); 72 | 73 | assertFalse(reader.didOverflow()); 74 | reader.nextData(); 75 | assertFalse(reader.didOverflow()); 76 | } 77 | 78 | @Test 79 | public void testNoOverflow() { 80 | BaggageReader reader = makeBaggage(); 81 | 82 | reader.nextData(); 83 | assertNull(reader.overflowAtoms()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/test/java/brown/tracingplane/baggageprotocol/TestBaggage07_EmptyBags.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | import java.nio.ByteBuffer; 6 | import java.util.List; 7 | import org.junit.Test; 8 | import com.google.common.collect.Lists; 9 | import brown.tracingplane.atomlayer.ByteBuffers; 10 | 11 | /** 12 | * Tests a baggage containing a bag that contains a bag that contains ... 13 | * 14 | * Checks that if an empty bag is added, then it isn't included in serialized form 15 | */ 16 | public class TestBaggage07_EmptyBags extends BaggageTestCase { 17 | 18 | private final BagKey.Indexed A = indexed(4); 19 | private final BagKey.Indexed AA = indexed(9); 20 | private final BagKey.Indexed AAA = indexed(8282); 21 | 22 | private final List payloadA = Lists.newArrayList(randomBytes(100)); 23 | 24 | private void writePayloads(BaggageWriter writer, List payloads) { 25 | payloads.forEach(p -> ByteBuffers.copyTo(p, writer.newDataAtom(p.remaining()))); 26 | } 27 | 28 | private BaggageReader makeBaggage() { 29 | BaggageWriter writer = BaggageWriter.create(); 30 | 31 | { 32 | writer.enter(A); 33 | writePayloads(writer, payloadA); 34 | writer.enter(AA).enter(AAA); 35 | writer.exit().exit(); 36 | writer.exit(); 37 | } 38 | 39 | return BaggageReader.create(writer.atoms()); 40 | } 41 | 42 | @Test 43 | public void testEnter() { 44 | BaggageReader reader = makeBaggage(); 45 | assertTrue(reader.enter(A)); 46 | assertFalse(reader.enter(AA)); 47 | assertFalse(reader.hasNext()); 48 | reader.exit(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /baggageprotocol/core/src/test/java/brown/tracingplane/baggageprotocol/TestOverflowMarker.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.baggageprotocol; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertNull; 6 | import static org.junit.Assert.assertTrue; 7 | import java.nio.ByteBuffer; 8 | import org.junit.Test; 9 | import brown.tracingplane.atomlayer.ByteBuffers; 10 | 11 | public class TestOverflowMarker extends BaggageTestCase { 12 | 13 | @Test 14 | public void testWriteReadSimple() { 15 | ByteBuffer contents = randomBytes(10); 16 | 17 | BaggageWriter writer = BaggageWriter.create(); 18 | ByteBuffers.copyTo(contents, writer.newDataAtom(contents.remaining())); 19 | BaggageReader reader = BaggageReader.create(writer.atoms()); 20 | 21 | assertFalse(reader.didOverflow()); 22 | assertEquals(contents, reader.nextData()); 23 | assertFalse(reader.didOverflow()); 24 | 25 | reader.finish(); 26 | assertNull(reader.overflowAtoms()); 27 | } 28 | 29 | @Test 30 | public void testWriteReadSimpleWithOverflow() { 31 | ByteBuffer contents = randomBytes(10); 32 | 33 | BaggageWriter writer = BaggageWriter.create(); 34 | writer.didOverflowHere(true); 35 | ByteBuffers.copyTo(contents, writer.newDataAtom(contents.remaining())); 36 | BaggageReader reader = BaggageReader.create(writer.atoms()); 37 | 38 | assertTrue(reader.didOverflow()); 39 | assertEquals(contents, reader.nextData()); 40 | assertTrue(reader.didOverflow()); 41 | 42 | reader.finish(); 43 | assertOverflowPath(reader.overflowAtoms()); 44 | } 45 | 46 | @Test 47 | public void testWriteReadSimpleWithOverflow2() { 48 | ByteBuffer contents = randomBytes(10); 49 | BagKey key = indexed(0); 50 | 51 | BaggageWriter writer = BaggageWriter.create(); 52 | writer.enter(key); 53 | ByteBuffers.copyTo(contents, writer.newDataAtom(contents.remaining())); 54 | writer.didOverflowHere(true); 55 | BaggageReader reader = BaggageReader.create(writer.atoms()); 56 | 57 | assertFalse(reader.didOverflow()); 58 | assertEquals(key, reader.enter()); 59 | assertFalse(reader.didOverflow()); 60 | assertEquals(contents, reader.nextData()); 61 | assertTrue(reader.didOverflow()); 62 | 63 | reader.finish(); 64 | assertOverflowPath(reader.overflowAtoms(), key); 65 | } 66 | 67 | @Test 68 | public void testFirstOverflowPathTaken() { 69 | BaggageWriter writer = BaggageWriter.create(); 70 | writer.enter(indexed(3)); 71 | writer.enter(indexed(5)).exit(); 72 | writer.enter(indexed(6)).didOverflowHere(true).exit(); 73 | writer.exit(); 74 | writer.enter(indexed(10)).didOverflowHere(true).exit(); 75 | 76 | BaggageReader reader = BaggageReader.create(writer.atoms()); 77 | reader.finish(); 78 | assertTrue(reader.didOverflow()); 79 | 80 | assertOverflowPath(reader.overflowAtoms(), indexed(3), indexed(6)); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /baggageprotocol/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | baggageprotocol 6 | pom 7 | 8 | Baggage Protocol 9 | 10 | 11 | core 12 | baggagecontext-impl 13 | 14 | 15 | 16 | brown.tracingplane 17 | tracingplane-project 18 | 1.0 19 | 20 | 21 | 22 | ${basedir}/.. 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | bdl-baggagecontext 6 | jar 7 | 8 | Baggage Definition Language - BaggageContext Impl 9 | 10 | 11 | brown.tracingplane 12 | bdl 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | bdl-core 24 | ${project.version} 25 | 26 | 27 | junit 28 | junit 29 | 30 | 31 | com.typesafe 32 | config 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/src/main/java/brown/tracingplane/BaggageListener.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | import java.util.function.BiFunction; 4 | import java.util.function.Function; 5 | import brown.tracingplane.BaggageContext; 6 | import brown.tracingplane.BaggageProvider; 7 | 8 | /** 9 | * A {@link BaggageListener} is a callback handler that is invoked whenever core {@link BaggageProvider} functions 10 | * (branch, merge, etc.) are invoked. Baggage Listeners are able to manipulate baggage instances before and after the 11 | * functions are called. 12 | * 13 | * A {@link BaggageProvider} must support adding {@link BaggageListener}s. 14 | */ 15 | public final class BaggageListener { 16 | 17 | /** BaggageListeners is not instantiable */ 18 | private BaggageListener() {} 19 | 20 | /** 21 | * Wraps calls to {@link BaggageProvider#branch(BaggageContext)} so that the baggage instance(s) can be modified. 22 | */ 23 | @FunctionalInterface 24 | public static interface BranchListener { 25 | 26 | /** 27 | * Invoked when {@link BaggageProvider#branch(BaggageContext)} is called. wrapped is the default 28 | * implementation of branch which should be called. This method can optionally perform additional logic before 29 | * or after invocation, or override its behavior completely. 30 | * 31 | * @param from a baggage context, possibly null 32 | * @param wrapped the default {@link BaggageProvider#branch(BaggageContext)} function 33 | * @return a baggage context branched from from, possibly null 34 | */ 35 | public B branch(B from, Function wrapped); 36 | } 37 | 38 | /** 39 | * Wraps calls to {@link BaggageProvider#join(BaggageContext, BaggageContext)} so that baggage instance(s) can be 40 | * modified. 41 | */ 42 | @FunctionalInterface 43 | public static interface JoinListener { 44 | 45 | /** 46 | * Invoked when {@link BaggageProvider#join(BaggageContext, BaggageContext)} is called. wrapped is 47 | * the default implementation of join which should be called. This method can optionally perform additional 48 | * logic before or after invocation, or override its behavior completely. 49 | * 50 | * @param left a {@link BaggageContext} instance, possibly null 51 | * @param right a {@link BaggageContext} instance, possibly null 52 | * @param next the default {@link BaggageProvider#join(BaggageContext, BaggageContext)} function 53 | * @return a baggage context with merged contents from left and right 54 | */ 55 | public B join(B left, B right, BiFunction wrapped); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/src/main/java/brown/tracingplane/impl/BDLContextProviderFactory.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import brown.tracingplane.BaggageContext; 4 | import brown.tracingplane.BaggageProvider; 5 | import brown.tracingplane.BaggageProviderFactory; 6 | 7 | /** 8 | * {@link BaggageProviderFactory} for {@link BDLContextProvider} 9 | */ 10 | public class BDLContextProviderFactory implements BaggageProviderFactory { 11 | 12 | @Override 13 | public BaggageProvider provider() { 14 | return new BDLContextProvider(BaggageHandlerRegistry.instance); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | # The mapping of bags to baggage handlers is done via the 'bags' configuration key 2 | bag { 3 | # Example registration: 4 | # 10 = "brown.xtrace.XTraceBaggage" 5 | } -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/src/test/java/brown/tracingplane/impl/TestBBUtils.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import org.junit.Test; 5 | 6 | public class TestBBUtils { 7 | 8 | @Test 9 | public void testSerializedSize() { 10 | assertEquals(0, BDLContextUtils.serializedSize(null)); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /bdl/baggagecontext-impl/src/test/java/brown/tracingplane/impl/TestBaggageRegistry.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.impl; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import org.junit.Test; 5 | import com.typesafe.config.Config; 6 | import com.typesafe.config.ConfigFactory; 7 | import com.typesafe.config.ConfigValueFactory; 8 | import brown.tracingplane.baggageprotocol.BagKey; 9 | import brown.tracingplane.baggageprotocol.BaggageReader; 10 | import brown.tracingplane.baggageprotocol.BaggageWriter; 11 | import brown.tracingplane.bdl.Bag; 12 | import brown.tracingplane.bdl.BaggageHandler; 13 | 14 | public class TestBaggageRegistry { 15 | 16 | @Test 17 | public void testEmptyByDefault() { 18 | 19 | BaggageHandlerRegistry defaultregistry = BaggageHandlerRegistry.create(); 20 | 21 | assertEquals(0, defaultregistry.registrations.keys.length); 22 | assertEquals(0, defaultregistry.registrations.handlers.length); 23 | 24 | } 25 | 26 | private static class BaggageHandlerForTest implements BaggageHandler { 27 | 28 | @Override 29 | public BagForTest parse(BaggageReader reader) { 30 | return null; 31 | } 32 | 33 | @Override 34 | public void serialize(BaggageWriter writer, BagForTest instance) {} 35 | 36 | @Override 37 | public BagForTest join(BagForTest first, BagForTest second) { 38 | return null; 39 | } 40 | 41 | @Override 42 | public BagForTest branch(BagForTest from) { 43 | return null; 44 | } 45 | 46 | @Override 47 | public boolean isInstance(Bag bag) { 48 | return false; 49 | } 50 | } 51 | 52 | private static BaggageHandlerForTest handler = new BaggageHandlerForTest(); 53 | 54 | private static class BagForTest implements Bag { 55 | 56 | @Override 57 | public BaggageHandler handler() { 58 | return handler; 59 | } 60 | 61 | } 62 | 63 | @Test 64 | public void testHandlerReflection() { 65 | Config config = 66 | ConfigFactory.load().withValue("bag.30", ConfigValueFactory.fromAnyRef(BagForTest.class.getName())); 67 | BaggageHandlerRegistry registry = BaggageHandlerRegistry.create(config); 68 | 69 | assertEquals(1, registry.registrations.keys.length); 70 | assertEquals(1, registry.registrations.handlers.length); 71 | assertEquals(BagKey.indexed(30), registry.registrations.keys[0]); 72 | assertEquals(handler, registry.registrations.handlers[0]); 73 | 74 | BaggageHandlerForTest handler2 = new BaggageHandlerForTest(); 75 | registry.doAdd(BagKey.indexed(5), handler2); 76 | 77 | assertEquals(2, registry.registrations.keys.length); 78 | assertEquals(2, registry.registrations.handlers.length); 79 | assertEquals(BagKey.indexed(5), registry.registrations.keys[0]); 80 | assertEquals(handler2, registry.registrations.handlers[0]); 81 | assertEquals(BagKey.indexed(30), registry.registrations.keys[1]); 82 | assertEquals(handler, registry.registrations.handlers[1]); 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /bdl/compiler/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /bdl/compiler/src/main/java/brown/tracingplane/bdl/compiler/BBC.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.compiler; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | import org.apache.log4j.PropertyConfigurator; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import com.beust.jcommander.JCommander; 10 | import com.beust.jcommander.Parameter; 11 | import com.beust.jcommander.Parameters; 12 | import brown.tracingplane.bdl.compiler.JavaCompiler; 13 | import brown.tracingplane.bdl.compiler.Ast.BaggageBuffersDeclaration; 14 | 15 | public class BBC { 16 | 17 | public static final String version = "0.1.alpha"; 18 | 19 | private static final Logger log = LoggerFactory.getLogger(BBC.class); 20 | 21 | /** Command line parameters */ 22 | @Parameters(separators = "=") 23 | public static class Settings { 24 | 25 | @Parameter(names = { "--bag_path" }, 26 | description = "Specify the directory in which to search for imports. May be specified multiple times; directories will be searched in order. If not given, the current working directory is used.") 27 | String bagPath = "."; 28 | 29 | @Parameter(names = { "--version" }, description = "Show version info and exit.") 30 | boolean version = false; 31 | 32 | @Parameter(names = { "-h", "--help" }, help = true) 33 | boolean help = false; 34 | 35 | @Parameter(names = { "--java_out" }, description = "Output directory to generate Java source files") 36 | String javaOut = null; 37 | 38 | @Parameter(description = "file1 file2 ...") 39 | List files = new ArrayList<>(); 40 | 41 | } 42 | 43 | public static void compile(Settings settings) throws CompileException { 44 | Set linked = Linker.link(settings); 45 | if (settings.javaOut != null) { 46 | new JavaCompiler().compile(settings.javaOut, linked); 47 | } 48 | } 49 | 50 | public static void main(String[] args) { 51 | PropertyConfigurator.configure(BBC.class.getClassLoader().getResourceAsStream("log4j-bbcompiler.properties")); 52 | 53 | // Parse the args 54 | Settings settings = new Settings(); 55 | JCommander jc = new JCommander(settings, args); 56 | jc.setProgramName("bbc"); 57 | 58 | if (settings.help) { 59 | jc.usage(); 60 | return; 61 | } 62 | 63 | if (settings.version) { 64 | System.out.println("bbc " + version); 65 | return; 66 | } 67 | 68 | if (settings.files.size() <= 0) { 69 | System.out.println("Missing input file."); 70 | return; 71 | } 72 | 73 | try { 74 | compile(settings); 75 | } catch (Exception e) { 76 | log.error(e.getMessage()); 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /bdl/compiler/src/main/java/brown/tracingplane/bdl/compiler/Compiler.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.compiler; 2 | 3 | import java.util.Collection; 4 | import brown.tracingplane.bdl.compiler.Ast.BaggageBuffersDeclaration; 5 | import brown.tracingplane.bdl.compiler.Ast.ObjectDeclaration; 6 | 7 | public interface Compiler { 8 | 9 | public default void compile(String outputDir, Collection bbDecls) { 10 | bbDecls.forEach(decl -> compile(outputDir, decl)); 11 | } 12 | 13 | public default void compile(String outputDir, BaggageBuffersDeclaration bbDecl) { 14 | bbDecl.getObjectDeclarations().forEach(objectDecl -> compile(outputDir, objectDecl)); 15 | } 16 | 17 | public void compile(String outputDir, ObjectDeclaration objectDecl); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /bdl/compiler/src/main/java/brown/tracingplane/bdl/compiler/FileUtils.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.compiler; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.nio.charset.Charset; 7 | import java.util.List; 8 | import org.apache.commons.lang3.StringUtils; 9 | import com.google.common.collect.Lists; 10 | 11 | /** Useful methods to do with reading files */ 12 | public class FileUtils { 13 | 14 | private FileUtils() {} 15 | 16 | 17 | public static List splitBagPath(String bagPath) { 18 | return Lists.newArrayList(StringUtils.split(bagPath, File.pathSeparator)); 19 | } 20 | 21 | public static String joinBagPath(List bagPathElements) { 22 | return StringUtils.join(bagPathElements, File.pathSeparator); 23 | } 24 | 25 | 26 | /** 27 | * Simply gets the File object for the file with the specified name, but also checks if it exists and is readable 28 | * @param fileName the name of the file to get 29 | * @return a {@link File} object for this fileName or null if it could not be found 30 | */ 31 | public static File getFile(String fileName) { 32 | File f = new File(fileName).getAbsoluteFile(); 33 | if (f.exists() && f.isFile() && f.canRead()) { 34 | return f; 35 | } else { 36 | return null; 37 | } 38 | } 39 | 40 | /** 41 | * Search several directories for a file with the specified filename. Ignores files if they are not readable. 42 | * 43 | * @param fileName the name of the file to search for 44 | * @param directories directories to search 45 | * @return a {@link File} object for this fileName, or null if no file could be found in any of the directories 46 | */ 47 | public static File findFile(String fileName, List directories) { 48 | for (String directory : directories) { 49 | File f = new File(directory, fileName); 50 | if (f.exists() && f.isFile() && f.canRead()) { 51 | return f; 52 | } 53 | } 54 | return null; 55 | } 56 | 57 | /** 58 | * Read the entire contents of a file as a String 59 | * 60 | * @param file the file to read 61 | * @return the contents of the file 62 | * @throws IOException if the file cannot be read for some reason 63 | */ 64 | public static String readFully(File file) throws IOException { 65 | FileInputStream fis = new FileInputStream(file); 66 | byte[] data = new byte[(int) file.length()]; 67 | fis.read(data); 68 | fis.close(); 69 | return new String(data, Charset.defaultCharset()); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /bdl/compiler/src/main/resources/example.bb: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.example; 2 | 3 | bag SimpleBag { 4 | 5 | set ids = 1; 6 | } 7 | 8 | bag SimpleBag2 { 9 | 10 | int32 first_field = 1; 11 | string second_field = 2; 12 | } 13 | 14 | bag ExampleBag { 15 | 16 | bool boolfield = 0; 17 | 18 | int32 int32field = 1; 19 | sint32 sint32field = 2; 20 | fixed32 fixed32field = 3; 21 | sfixed32 sfixed32field = 4; 22 | 23 | int64 int64field = 5; 24 | sint64 sint64field = 6; 25 | fixed64 fixed64field = 7; 26 | sfixed64 sfixed64field = 8; 27 | 28 | string stringfield = 9; 29 | bytes bytesfield = 10; 30 | 31 | set int32set = 11; 32 | set stringset = 12; 33 | 34 | SimpleBag simple_bag = 15; 35 | 36 | Set simple_bag_2 = 16; 37 | 38 | 39 | Map bag_map = 20; 40 | 41 | } -------------------------------------------------------------------------------- /bdl/compiler/src/main/resources/log4j-bbcompiler.properties: -------------------------------------------------------------------------------- 1 | # Root logger option 2 | log4j.rootLogger=INFO, stdout 3 | 4 | # Direct log messages to stdout 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.Target=System.out 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 9 | -------------------------------------------------------------------------------- /bdl/compiler/src/main/scala/brown/tracingplane/bdl/compiler/Parser.scala: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.compiler 2 | 3 | import brown.tracingplane.bdl.compiler.Ast._ 4 | import brown.tracingplane.bdl.compiler.Declarations._ 5 | import fastparse.all._ 6 | import org.apache.commons.lang3.StringUtils 7 | 8 | object Parser { 9 | 10 | /** One-line comment beginning with double slash */ 11 | val comment1 = P( "//" ~ CharsWhile(_ != '\n') ~ "\n" ).map{ case _ => "\n" } 12 | val comment2 = P( "/*" ~ (!"*/" ~ AnyChar).rep ~ ("*/" | End) ).map{ case _ => "" } 13 | val trailingComment1 = P( "//" ~ AnyChar.rep ~ End ).map{ case _ => "" } 14 | val removeComments = P ( (comment1 | trailingComment1 | comment2 | AnyChar.!).rep ).map(_.mkString("")) 15 | 16 | @throws[ParseError] 17 | def parse[T](parser: P[T], text: String): T = { 18 | parser.parse(text) match { 19 | case failure: Parsed.Failure => throw ParseError(failure) 20 | case Parsed.Success(res, i) => { 21 | if (i == text.length()) { 22 | return res 23 | } else { 24 | val unexpected = StringUtils.abbreviate(text.substring(i), 20); 25 | throw new Exception("Unexpected text at index " + i + " \"" + unexpected + "\""); 26 | } 27 | } 28 | } 29 | } 30 | 31 | def removeComments(text: String): String = { 32 | return parse(removeComments, text); 33 | } 34 | 35 | @throws[ParseError] 36 | def parseBaggageBuffersFile(text: String): BaggageBuffersDeclaration = { 37 | val bbDecl = parse(bbDeclaration, removeComments(text)) 38 | if (bbDecl.isEmpty) { 39 | throw new Exception("No BaggageBuffers declaration to parse") 40 | } else { 41 | return bbDecl 42 | } 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /bdl/core/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | bin 5 | target 6 | xtrace-data 7 | application.conf -------------------------------------------------------------------------------- /bdl/core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | bdl-core 6 | jar 7 | 8 | Baggage Definition Language - Core 9 | 10 | 11 | brown.tracingplane 12 | bdl 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | baggageprotocol-core 24 | ${project.version} 25 | 26 | 27 | junit 28 | junit 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/BDLUtils.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import java.util.function.Function; 8 | import com.google.common.collect.Lists; 9 | import brown.tracingplane.atomlayer.StringUtils; 10 | 11 | public class BDLUtils { 12 | 13 | public static String toString(Set set) { 14 | return set == null ? "{ }" : "{ " + StringUtils.join(set, ", ") + " }"; 15 | } 16 | 17 | public static String toString(Map map, Function valueToStringFunction) { 18 | if (map == null) { 19 | return "{ }"; 20 | } 21 | List strings = new ArrayList<>(); 22 | for (Object key : map.keySet()) { 23 | strings.add(String.valueOf(key) + " = " + map.get(key)); 24 | } 25 | return formatChild(StringUtils.join(strings, "\n")); 26 | } 27 | 28 | public static String toString(Bag bag) { 29 | return bag == null ? "{ }" : formatChild(indent(bag.toString())); 30 | } 31 | 32 | public static String formatChild(String s) { 33 | return StringUtils.join(Lists.newArrayList("{", indent(s), "}"), "\n"); 34 | } 35 | 36 | public static String indent(String s) { 37 | return s.replaceAll("(?m)^", " "); 38 | } 39 | 40 | /** 41 | * Equality comparison, using the provided default value if a or b are null 42 | * @param a an object instance, possibly null 43 | * @param b an object instance, possibly null 44 | * @param defaultValue the default value to use for a or b if they happen to be null 45 | * @return true if a and b are equal 46 | */ 47 | public static boolean equals(T a, T b, T defaultValue) { 48 | if (a == null && b == null) { 49 | return true; 50 | } else if (a == null) { 51 | return b.equals(defaultValue); 52 | } else if (b == null) { 53 | return a.equals(defaultValue); 54 | } else { 55 | return a.equals(b); 56 | } 57 | } 58 | 59 | // This is a hack to add 'compaction' joins without deploying them to all the interfaces. 60 | // At this point in time it's still a question of whether compact joins are useful 61 | public static final ThreadLocal is_compaction = new ThreadLocal() { 62 | @Override public Boolean initialValue() { 63 | return false; 64 | } 65 | }; 66 | 67 | } 68 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Bag.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | /** 4 | * The BDL compiler generates classes that implement this interface, Bag. They also generate BaggageHandler 5 | * implementations 6 | * 7 | * Bags are propagated by the Tracing Plane across all execution boundaries. They define semantics for branching, 8 | * joining, serializing, and trimming. 9 | */ 10 | public interface Bag { 11 | 12 | BaggageHandler handler(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/BaggageHandler.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import brown.tracingplane.baggageprotocol.BaggageWriter; 4 | 5 | /** 6 | *

7 | * Provides serialization, deserialization, branch, and merge logic for a bag type. 8 | *

9 | */ 10 | public interface BaggageHandler extends Parser, Serializer, Joiner, Brancher { 11 | 12 | public boolean isInstance(Bag bag); 13 | 14 | @SuppressWarnings("unchecked") 15 | public default void serialize(BaggageWriter writer, Bag bag) { 16 | if (isInstance(bag)) { 17 | ((Serializer) this).serialize(writer, (T) bag); 18 | } 19 | } 20 | 21 | @SuppressWarnings("unchecked") 22 | public default T join(Bag first, Bag second) { 23 | if (isInstance(first)) { 24 | if (isInstance(second)) { 25 | return ((Joiner) this).join((T) first, (T) second); 26 | } else { 27 | return (T) first; 28 | } 29 | } else { 30 | if (isInstance(second)) { 31 | return (T) second; 32 | } else { 33 | return null; 34 | } 35 | } 36 | } 37 | 38 | @SuppressWarnings("unchecked") 39 | public default T branch(Bag from) { 40 | if (isInstance(from)) { 41 | return ((Brancher) this).branch((T) from); 42 | } else { 43 | return null; 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Brancher.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | public interface Brancher { 4 | 5 | public T branch(T from); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Branchers.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import java.util.HashMap; 4 | import java.util.HashSet; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | /** 9 | * Branch logic for primitive BDL types {@link #noop()}, sets, and maps. 10 | */ 11 | public class Branchers { 12 | 13 | private Branchers() {} 14 | 15 | /** Copies nothing and reuses the original object */ 16 | public static Brancher noop() { 17 | return new Brancher() { 18 | public T branch(T from) { 19 | return from; 20 | } 21 | }; 22 | } 23 | 24 | public static Brancher> set() { 25 | return new Brancher>() { 26 | public Set branch(Set from) { 27 | return from == null ? null : new HashSet(from); 28 | } 29 | }; 30 | } 31 | 32 | public static Brancher> map(Brancher valueBrancher) { 33 | return new Brancher>() { 34 | public Map branch(Map from) { 35 | if (from == null) { 36 | return null; 37 | } 38 | Map branched = new HashMap<>(); 39 | for (K key : from.keySet()) { 40 | branched.put(key, valueBrancher.branch(from.get(key))); 41 | } 42 | return branched; 43 | } 44 | }; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Joiner.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | public interface Joiner { 4 | 5 | public T join(T first, T second); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Joiners.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | 6 | /** 7 | * Merge logic for primitive BDL types {@link #first()}, sets, and maps. 8 | */ 9 | public class Joiners { 10 | 11 | private Joiners() {} 12 | 13 | public static Joiner or() { 14 | return new Joiner() { 15 | public Boolean join(Boolean a, Boolean b) { 16 | if (a == null) { 17 | return b; 18 | } else if (b == null) { 19 | return a; 20 | } else { 21 | return a || b; 22 | } 23 | } 24 | }; 25 | } 26 | 27 | public static Joiner first() { 28 | return new Joiner() { 29 | public T join(T a, T b) { 30 | return a == null ? b : a; 31 | } 32 | }; 33 | } 34 | 35 | public static Joiner> setUnion() { 36 | return new Joiner>() { 37 | public Set join(Set firstSet, Set secondSet) { 38 | if (firstSet == null) { 39 | return secondSet; 40 | } else if (secondSet == null) { 41 | return firstSet; 42 | } else { 43 | firstSet.addAll(secondSet); 44 | return firstSet; 45 | } 46 | } 47 | }; 48 | } 49 | 50 | public static Joiner> mapMerge(Joiner valueJoiner) { 51 | return new Joiner>() { 52 | public Map join(Map firstMap, Map secondMap) { 53 | if (firstMap == null) { 54 | return secondMap; 55 | } else if (secondMap == null) { 56 | return firstMap; 57 | } else { 58 | for (K key : secondMap.keySet()) { 59 | if (firstMap.containsKey(key)) { 60 | firstMap.put(key, valueJoiner.join(firstMap.get(key), secondMap.get(key))); 61 | } else { 62 | firstMap.put(key, secondMap.get(key)); 63 | } 64 | } 65 | return firstMap; 66 | } 67 | } 68 | }; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Parser.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import brown.tracingplane.baggageprotocol.BaggageReader; 4 | import brown.tracingplane.baggageprotocol.ElementReader; 5 | 6 | public interface Parser { 7 | 8 | public T parse(BaggageReader reader); 9 | 10 | public static interface ElementParser extends Parser { 11 | 12 | @Override 13 | public default T parse(BaggageReader reader) { 14 | return parse((ElementReader) reader); 15 | } 16 | 17 | public T parse(ElementReader reader); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/ReaderHelpers.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Collection; 5 | import java.util.function.BiFunction; 6 | import java.util.function.Function; 7 | import java.util.function.Predicate; 8 | import java.util.function.Supplier; 9 | import brown.tracingplane.baggageprotocol.ElementReader; 10 | 11 | /** 12 | * Helper methods used by compiled baggagebuffers classes 13 | */ 14 | public class ReaderHelpers { 15 | 16 | private ReaderHelpers() {} 17 | 18 | public static final Function to_bool = buf -> Cast.to_bool(buf); 19 | public static final Function to_int32 = buf -> Cast.to_int32(buf); 20 | public static final Function to_sint32 = buf -> Cast.to_sint32(buf); 21 | public static final Function to_fixed32 = buf -> Cast.to_fixed32(buf); 22 | public static final Function to_sfixed32 = buf -> Cast.to_sfixed32(buf); 23 | public static final Function to_int64 = buf -> Cast.to_int64(buf); 24 | public static final Function to_sint64 = buf -> Cast.to_sint64(buf); 25 | public static final Function to_fixed64 = buf -> Cast.to_fixed64(buf); 26 | public static final Function to_sfixed64 = buf -> Cast.to_sfixed64(buf); 27 | public static final Function to_float = buf -> Cast.to_float(buf); 28 | public static final Function to_double = buf -> Cast.to_double(buf); 29 | public static final Function to_string = buf -> Cast.to_string(buf); 30 | public static final Function to_bytes = buf -> Cast.to_bytes(buf); 31 | 32 | /** Find the next data item that matches the provided predicate */ 33 | public static ByteBuffer filterNext(ElementReader reader, Predicate filter) { 34 | ByteBuffer buf; 35 | while ((buf = reader.nextData()) != null) { 36 | if (filter.test(buf)) { 37 | return buf; 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | /** 44 | * Get the next data item and transform bytebuffer to type using the provided function. If the cast function returns 45 | * null, it will move on to the next data item. 46 | */ 47 | public static T castNext(ElementReader reader, Function cast) { 48 | ByteBuffer buf = null; 49 | T out = null; 50 | while ((buf = reader.nextData()) != null) { 51 | if ((out = cast.apply(buf)) != null) { 52 | return out; 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | public static Out combine(ElementReader reader, Function cast, 59 | Supplier defaultValueGenerator, BiFunction combiner) { 60 | Out combined = null; 61 | In next = null; 62 | while ((next = castNext(reader, cast)) != null) { 63 | if (combined == null) { 64 | combined = defaultValueGenerator.get(); 65 | } 66 | combined = combiner.apply(combined, next); 67 | } 68 | return combined; 69 | } 70 | 71 | public static > Out collect(ElementReader reader, Function cast, 72 | Supplier defaultValueGenerator) { 73 | return combine(reader, cast, defaultValueGenerator, (collection, value) -> { 74 | collection.add(value); 75 | return collection; 76 | }); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Serializer.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import brown.tracingplane.baggageprotocol.BaggageWriter; 4 | import brown.tracingplane.baggageprotocol.ElementWriter; 5 | 6 | public interface Serializer { 7 | 8 | public void serialize(BaggageWriter writer, T instance); 9 | 10 | /** A serializer that only serializes data elements and not bags */ 11 | public static interface ElementSerializer extends Serializer { 12 | 13 | @Override 14 | public default void serialize(BaggageWriter writer, T instance) { 15 | serialize((ElementWriter) writer, instance); 16 | } 17 | 18 | public void serialize(ElementWriter writer, T instance); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/SpecialTypes.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | /** 4 | * Defines the interfaces for special BDL types such as {@link Counter} 5 | */ 6 | public class SpecialTypes { 7 | 8 | /** 9 | * A P-Counter CRDT, corresponding to the {@code counter} BDL type 10 | */ 11 | public interface Counter extends Bag { 12 | 13 | public static Counter newInstance() { 14 | return new CounterImpl(); 15 | } 16 | 17 | public void increment(); 18 | 19 | public void increment(long quantity); 20 | 21 | public long getValue(); 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/Struct.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import java.nio.ByteBuffer; 4 | import brown.tracingplane.baggageprotocol.ElementReader; 5 | import brown.tracingplane.baggageprotocol.ElementWriter; 6 | import brown.tracingplane.bdl.Parser.ElementParser; 7 | import brown.tracingplane.bdl.Serializer.ElementSerializer; 8 | 9 | /** 10 | * BDL supports structs, which are simply several data types combined into a single binary blob and 11 | * encoded as one atom. 12 | */ 13 | public interface Struct { 14 | 15 | StructHandler handler(); 16 | 17 | @FunctionalInterface 18 | public interface StructReader { 19 | public S readFrom(ByteBuffer buf) throws Exception; 20 | } 21 | 22 | @FunctionalInterface 23 | public interface StructSizer { 24 | public int serializedSize(S struct); 25 | } 26 | 27 | @FunctionalInterface 28 | public interface StructWriter { 29 | public void writeTo(ByteBuffer buf, S struct) throws Exception; 30 | } 31 | 32 | public interface StructHandler 33 | extends StructReader, StructWriter, StructSizer, ElementParser, ElementSerializer { 34 | 35 | @Override 36 | public default S parse(ElementReader reader) { 37 | ByteBuffer buf = null; 38 | S out = null; 39 | while ((buf = reader.nextData()) != null) { 40 | try { 41 | out = readFrom(buf); 42 | } catch (Exception e) { 43 | // Ignore and continue 44 | } 45 | if (out != null) { 46 | return out; 47 | } 48 | } 49 | return null; 50 | } 51 | 52 | @Override 53 | public default void serialize(ElementWriter writer, S instance) { 54 | if (instance != null) { 55 | int size = serializedSize(instance); 56 | ByteBuffer atom = writer.newDataAtom(size); 57 | try { 58 | writeTo(atom, instance); 59 | } catch (Exception e) { 60 | // Leave it for now 61 | } 62 | } 63 | } 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /bdl/core/src/main/java/brown/tracingplane/bdl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * Library classes used by BDL-generated objects, including the {@link BDLContext} implementation of 4 | * {@link BaggageContext}. 5 | *

6 | * 7 | *

8 | * The two main interfaces used by BDL are {@link Bag} and {@link BaggageHandler}. {@link Bag}s are nodes in the nested 9 | * data structure tree, while {@link BaggageHandler}s provide branch, join, and serialization logic for {@link Bag}s. 10 | * {@link Bag} and {@link BaggageHandler} are conceptually similar to {@link BaggageContext} and {@link BaggageProvider} 11 | * , except applying to nodes within a {@link BDLContext}. 12 | *

13 | * 14 | *

15 | * The BDL library classes also include CRDT-like data structures that the BDL supports, such as counters, implemented 16 | * by {@link CounterImpl}. 17 | *

18 | */ 19 | package brown.tracingplane.bdl; 20 | -------------------------------------------------------------------------------- /bdl/core/src/test/java/brown/tracingplane/bdl/TestCounterImpl.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import org.junit.Test; 5 | import brown.tracingplane.bdl.SpecialTypes.Counter; 6 | 7 | public class TestCounterImpl { 8 | 9 | @Test 10 | public void testCounterImpl() { 11 | 12 | Counter counter = new CounterImpl(); 13 | 14 | assertEquals(0L, counter.getValue()); 15 | 16 | for (int i = 0; i < 100; i++) { 17 | assertEquals((long) i, counter.getValue()); 18 | counter.increment(); 19 | assertEquals((long) (i + 1), counter.getValue()); 20 | } 21 | 22 | BaggageHandler handler = counter.handler(); 23 | 24 | Counter c2 = (Counter) handler.branch(counter); 25 | 26 | assertEquals(100, counter.getValue()); 27 | 28 | assertEquals(100, c2.getValue()); 29 | 30 | for (int i = 0; i < 50; i++) { 31 | assertEquals(100 + i, counter.getValue()); 32 | assertEquals(100, c2.getValue()); 33 | counter.increment(); 34 | assertEquals(100 + (i + 1), counter.getValue()); 35 | assertEquals(100, c2.getValue()); 36 | } 37 | 38 | for (int i = 0; i < 50; i++) { 39 | assertEquals(100 + i, c2.getValue()); 40 | assertEquals(150, counter.getValue()); 41 | c2.increment(); 42 | assertEquals(100 + (i + 1), c2.getValue()); 43 | assertEquals(150, counter.getValue()); 44 | } 45 | 46 | assertEquals(150, counter.getValue()); 47 | assertEquals(150, c2.getValue()); 48 | 49 | Counter c3 = (Counter) handler.join(counter, c2); 50 | 51 | assertEquals(200, c3.getValue()); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bdl/core/src/test/java/brown/tracingplane/bdl/TestStructHelpers.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import java.nio.ByteBuffer; 5 | import org.junit.Test; 6 | 7 | public class TestStructHelpers { 8 | 9 | @Test 10 | public void testStructReadWrite() throws Exception { 11 | ByteBuffer buf = ByteBuffer.allocate(100); 12 | 13 | StructHelpers.stringWriter.writeTo(buf, "hello"); 14 | StructHelpers.stringWriter.writeTo(buf, "again"); 15 | 16 | buf.flip(); 17 | 18 | assertEquals("hello", StructHelpers.stringReader.readFrom(buf)); 19 | assertEquals("again", StructHelpers.stringReader.readFrom(buf)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /bdl/examples/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /bdl/examples/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | bdl-examples 6 | jar 7 | 8 | Baggage Definition Language - Examples 9 | 10 | 11 | brown.tracingplane 12 | bdl 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | bdl-baggagecontext 24 | ${project.version} 25 | 26 | 27 | brown.tracingplane 28 | transitlayer 29 | ${project.version} 30 | 31 | 32 | junit 33 | junit 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.codehaus.mojo 41 | build-helper-maven-plugin 42 | 1.12 43 | 44 | 45 | include-baggagebuffers-source 46 | generate-sources 47 | 48 | add-source 49 | 50 | 51 | 52 | src/main/baggage 53 | 54 | 55 | 56 | 57 | 58 | 59 | maven-antrun-plugin 60 | 61 | 62 | generate-sources 63 | generate-sources 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | target/generated-sources 76 | 77 | 78 | run 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /bdl/examples/src/main/baggage/example.bb: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.examples; 2 | 3 | bag SimpleBag { 4 | 5 | set ids = 1; 6 | } 7 | 8 | bag SimpleBag2 { 9 | 10 | int32 first_field = 1; 11 | string second_field = 2; 12 | } 13 | 14 | struct SimpleStruct1 { 15 | 16 | int32 integer_field; 17 | string string_field; 18 | 19 | } 20 | 21 | struct SimpleStruct2 { 22 | int64 integer_field; 23 | SimpleStruct1 nested_struct; 24 | } 25 | 26 | 27 | bag ExampleBag { 28 | 29 | bool boolfield = 0; 30 | 31 | int32 int32field = 1; 32 | sint32 sint32field = 2; 33 | fixed32 fixed32field = 3; 34 | sfixed32 sfixed32field = 4; 35 | 36 | int64 int64field = 5; 37 | sint64 sint64field = 6; 38 | fixed64 fixed64field = 7; 39 | sfixed64 sfixed64field = 8; 40 | 41 | string stringfield = 9; 42 | bytes bytesfield = 10; 43 | 44 | set int32set = 11; 45 | set stringset = 12; 46 | 47 | SimpleBag simple_bag = 15; 48 | 49 | Set simple_bag_2 = 16; 50 | 51 | 52 | Map bag_map = 20; 53 | 54 | counter c = 23; 55 | 56 | 57 | taint sampled = 30; 58 | 59 | SimpleStruct1 structfield = 33; 60 | 61 | set structsetfield = 34; 62 | 63 | map countermap = 35; 64 | 65 | } 66 | 67 | bag FonsecaBag { 68 | map> publications_by_conference = 77; 69 | } -------------------------------------------------------------------------------- /bdl/examples/src/main/baggage/xtrace.bb: -------------------------------------------------------------------------------- 1 | package brown.xtrace; 2 | 3 | bag XTraceBaggage { 4 | 5 | fixed64 taskId = 1; 6 | 7 | set parentEventIds = 2; 8 | 9 | } -------------------------------------------------------------------------------- /bdl/examples/src/test/java/brown/tracingplane/bdl/examples/Example.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.examples; 2 | 3 | import java.util.HashMap; 4 | import java.util.HashSet; 5 | import brown.tracingplane.atomlayer.TypeUtils; 6 | import brown.tracingplane.baggageprotocol.BaggageWriter; 7 | 8 | public class Example { 9 | 10 | public static void main(String[] args) { 11 | ExampleBag b = new ExampleBag(); 12 | 13 | b.int32field = 7; 14 | 15 | b.int32set = new HashSet<>(); 16 | b.int32set.add(100); 17 | b.int32set.add(3); 18 | b.int32set.add(55); 19 | 20 | b.bagMap = new HashMap<>(); 21 | 22 | SimpleBag2 b2 = new SimpleBag2(); 23 | b2.firstField = 10000; 24 | 25 | SimpleBag2 b3 = new SimpleBag2(); 26 | b3.secondField = "boshank"; 27 | 28 | b.bagMap.put("jon", b2); 29 | b.bagMap.put("mace", b3); 30 | 31 | BaggageWriter writer = BaggageWriter.create(); 32 | 33 | ExampleBag.Handler.instance.serialize(writer, b); 34 | 35 | System.out.println(TypeUtils.toHexString(writer.atoms())); 36 | 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /bdl/examples/src/test/java/brown/tracingplane/bdl/examples/TestXTraceBaggage.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane.bdl.examples; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import org.junit.Test; 5 | import com.google.common.collect.Sets; 6 | import brown.tracingplane.BaggageContext; 7 | import brown.tracingplane.baggageprotocol.BagKey; 8 | import brown.tracingplane.impl.BDLContext; 9 | import brown.tracingplane.impl.BDLContextProvider; 10 | import brown.tracingplane.impl.BDLContextProviderFactory; 11 | import brown.tracingplane.impl.BaggageHandlerRegistry; 12 | import brown.xtrace.XTraceBaggage; 13 | 14 | public class TestXTraceBaggage { 15 | 16 | static { 17 | // Temporary registration for testing etc. 18 | BaggageHandlerRegistry.add(BagKey.indexed(0), XTraceBaggage.Handler.instance); 19 | } 20 | 21 | private static final BDLContextProvider provider = (BDLContextProvider) new BDLContextProviderFactory().provider(); 22 | 23 | @Test 24 | public void simpleTest() { 25 | // Create an XTraceBaggage object 26 | XTraceBaggage xmd = new XTraceBaggage(); 27 | xmd.taskId = 100L; 28 | xmd.parentEventIds = Sets.newHashSet(1000L, 300L, 200L); 29 | BaggageContext a = XTraceBaggage.setIn(null, xmd); 30 | 31 | // Create another XTraceBaggage object 32 | XTraceBaggage xmd2 = new XTraceBaggage(); 33 | xmd2.taskId = 100L; 34 | xmd2.parentEventIds = Sets.newHashSet(1000L, 500L); 35 | BaggageContext b = XTraceBaggage.setIn(null, xmd2); 36 | 37 | // Merge them explicitly 38 | BaggageContext b3 = provider.join(provider.branch((BDLContext) a), provider.branch((BDLContext) b)); 39 | 40 | // Get the merged XTraceBaggage 41 | XTraceBaggage xmd3 = XTraceBaggage.getFrom(b3); 42 | assertEquals(Long.valueOf(100L), xmd3.taskId); 43 | assertEquals(Sets.newHashSet(200L, 300L, 500L, 1000L), xmd3.parentEventIds); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bdl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | bdl 6 | pom 7 | 8 | Baggage Definition Language 9 | 10 | 11 | compiler 12 | core 13 | baggagecontext-impl 14 | examples 15 | 16 | 17 | 18 | brown.tracingplane 19 | tracingplane-project 20 | 1.0 21 | 22 | 23 | 24 | ${basedir}/.. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /dist/github/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | tracingplane-github 6 | pom 7 | 8 | Tracing Plane Distributions - Github Distribution 9 | 10 | 11 | brown.tracingplane 12 | tracingplane-dist-project 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | ${GITHUB_USERNAME} 20 | ${GITHUB_OAUTH_TOKEN} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | com.github.github 29 | site-maven-plugin 30 | 0.12 31 | 32 | Maven artifacts for ${project.version} 33 | true 34 | ${tracingplane.root}/target/mvn-repo 35 | refs/heads/mvn-repo 36 | 37 | **/* 38 | 39 | tracingplane-java 40 | tracingplane 41 | 42 | 43 | 44 | 45 | site 46 | 47 | deploy 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /dist/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | tracingplane-dist-project 6 | pom 7 | 8 | Tracing Plane Distributions 9 | 10 | 11 | tracingplane 12 | github 13 | 14 | 15 | 16 | brown.tracingplane 17 | tracingplane-project 18 | 1.0 19 | 20 | 21 | 22 | ${basedir}/.. 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /dist/tracingplane/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | brown.tracingplane 5 | tracingplane 6 | jar 7 | 8 | Tracing Plane Distributions - Main Distribution 9 | 10 | 11 | brown.tracingplane 12 | tracingplane-dist-project 13 | 1.0 14 | 15 | 16 | 17 | ${basedir}/../.. 18 | 19 | 20 | 21 | 22 | brown.tracingplane 23 | bdl-baggagecontext 24 | ${project.version} 25 | 26 | 27 | brown.tracingplane 28 | baggagecontext-staticapi 29 | ${project.version} 30 | 31 | 32 | brown.tracingplane 33 | transitlayer 34 | ${project.version} 35 | 36 | 37 | com.typesafe 38 | config 39 | 40 | 41 | junit 42 | junit 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-dependency-plugin 52 | 2.8 53 | 54 | 55 | copy-artifact 56 | package 57 | 58 | copy-dependencies 59 | 60 | 61 | ${project.build.directory}/lib 62 | true 63 | true 64 | true 65 | 66 | 67 | 68 | 69 | 70 | 71 | maven-assembly-plugin 72 | 3.0.0 73 | 74 | 75 | jar-with-dependencies 76 | 77 | 78 | 79 | 80 | make-assembly 81 | package 82 | 83 | single 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /dist/tracingplane/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | baggage.transit = "brown.tracingplane.impl.ThreadLocalTransitLayerFactory" 2 | baggage.provider = "brown.tracingplane.impl.BDLContextProviderFactory" -------------------------------------------------------------------------------- /dist/tracingplane/src/test/java/brown/tracingplane/TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package brown.tracingplane; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | import static org.junit.Assert.assertTrue; 5 | import org.junit.Test; 6 | import brown.tracingplane.impl.BDLContextProvider; 7 | import brown.tracingplane.impl.ThreadLocalTransitLayer; 8 | 9 | public class TestConfiguration { 10 | 11 | @Test 12 | public void testDefaultBaggageProviderIsBDLContextProvider() { 13 | BaggageProvider provider = DefaultBaggageProvider.get(); 14 | assertNotNull(provider); 15 | assertTrue(provider instanceof BDLContextProvider); 16 | } 17 | 18 | @Test 19 | public void testDefaultTransitLayerIsThreadLocalTransitLayer() { 20 | TransitLayer transit = DefaultTransitLayer.get(); 21 | assertNotNull(transit); 22 | assertTrue(transit instanceof ThreadLocalTransitLayer); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /doc/baggage-buffers-tutorial.md: -------------------------------------------------------------------------------- 1 | = Baggage Buffers Tutorial = 2 | 3 | Not implemented yet -------------------------------------------------------------------------------- /doc/brown/tracingplane/atomlayer/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.tracingplane.atomlayer 7 | 8 | 9 | 10 | 11 | 12 |

brown.tracingplane.atomlayer

13 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /doc/brown/tracingplane/bdl/compiler/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.tracingplane.bdl.compiler 7 | 8 | 9 | 10 | 11 | 12 |

brown.tracingplane.bdl.compiler

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 27 |

Exceptions

28 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/brown/tracingplane/bdl/examples/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.tracingplane.bdl.examples 7 | 8 | 9 | 10 | 11 | 12 |

brown.tracingplane.bdl.examples

13 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/brown/tracingplane/impl/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.tracingplane.impl 7 | 8 | 9 | 10 | 11 | 12 |

brown.tracingplane.impl

13 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/brown/tracingplane/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.tracingplane 7 | 8 | 9 | 10 | 11 | 12 |

brown.tracingplane

13 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /doc/brown/xtrace/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | brown.xtrace 7 | 8 | 9 | 10 | 11 | 12 |

brown.xtrace

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/figures/baggage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tracingplane/tracingplane-java/7e455073c12c4483b65676287a2e737404fe5cbc/doc/figures/baggage.png -------------------------------------------------------------------------------- /doc/figures/narrowwaist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tracingplane/tracingplane-java/7e455073c12c4483b65676287a2e737404fe5cbc/doc/figures/narrowwaist.png -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Generated Documentation (Untitled) 7 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | <noscript> 69 | <div>JavaScript is disabled on your browser.</div> 70 | </noscript> 71 | <h2>Frame Alert</h2> 72 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/baggage_buffers/gen/example/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.baggage_buffers.gen.example 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.baggage_buffers.gen.example

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/baggage_buffers_examples/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.baggage_buffers_examples 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.baggage_buffers_examples

13 |
14 |

Classes

15 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/atom_layer/impl/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.atom_layer.impl 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.atom_layer.impl

13 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/atom_layer/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.atom_layer 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.atom_layer

13 |
14 |

Interfaces

15 | 20 |

Classes

21 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/atom_layer/protocol/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.atom_layer.protocol 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.atom_layer.protocol

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/atom_layer/types/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.atom_layer.types 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.atom_layer.types

13 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_buffers/api/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_buffers.api 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_buffers.api

13 |
14 |

Interfaces

15 | 25 |

Classes

26 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_buffers/compiler/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_buffers.compiler 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_buffers.compiler

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 26 |

Exceptions

27 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_buffers/gen/xtrace/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_buffers.gen.xtrace 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_buffers.gen.xtrace

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_buffers/impl/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_buffers.impl 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_buffers.impl

13 |
14 |

Classes

15 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_buffers/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_buffers 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_buffers

13 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_layer/impl/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_layer.impl 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_layer.impl

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/baggage_layer/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.baggage_layer 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.baggage_layer

13 |
14 |

Interfaces

15 | 20 |

Classes

21 | 29 |

Enums

30 | 33 |

Exceptions

34 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/transit_layer/impl/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.transit_layer.impl 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.transit_layer.impl

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/cs/systems/tracingplane/transit_layer/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.cs.systems.tracingplane.transit_layer 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.cs.systems.tracingplane.transit_layer

13 |
14 |

Interfaces

15 | 20 |

Classes

21 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /doc/javadoc/edu/brown/xtrace/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | edu.brown.xtrace 7 | 8 | 9 | 10 | 11 | 12 |

edu.brown.xtrace

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/javadoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Generated Documentation (Untitled) 7 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | <noscript> 69 | <div>JavaScript is disabled on your browser.</div> 70 | </noscript> 71 | <h2>Frame Alert</h2> 72 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /doc/javadoc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Overview List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 34 |

 

35 | 36 | 37 | -------------------------------------------------------------------------------- /doc/javadoc/package-list: -------------------------------------------------------------------------------- 1 | edu.brown.cs.systems.baggage_buffers.gen.example 2 | edu.brown.cs.systems.baggage_buffers_examples 3 | edu.brown.cs.systems.tracingplane.atom_layer 4 | edu.brown.cs.systems.tracingplane.atom_layer.impl 5 | edu.brown.cs.systems.tracingplane.atom_layer.protocol 6 | edu.brown.cs.systems.tracingplane.atom_layer.types 7 | edu.brown.cs.systems.tracingplane.baggage_buffers 8 | edu.brown.cs.systems.tracingplane.baggage_buffers.api 9 | edu.brown.cs.systems.tracingplane.baggage_buffers.compiler 10 | edu.brown.cs.systems.tracingplane.baggage_buffers.impl 11 | edu.brown.cs.systems.tracingplane.baggage_layer 12 | edu.brown.cs.systems.tracingplane.baggage_layer.impl 13 | edu.brown.cs.systems.tracingplane.baggage_layer.protocol 14 | edu.brown.cs.systems.tracingplane.transit_layer 15 | edu.brown.cs.systems.tracingplane.transit_layer.impl 16 | edu.brown.xtrace 17 | -------------------------------------------------------------------------------- /doc/javadoc/script.js: -------------------------------------------------------------------------------- 1 | function show(type) 2 | { 3 | count = 0; 4 | for (var key in methods) { 5 | var row = document.getElementById(key); 6 | if ((methods[key] & type) != 0) { 7 | row.style.display = ''; 8 | row.className = (count++ % 2) ? rowColor : altColor; 9 | } 10 | else 11 | row.style.display = 'none'; 12 | } 13 | updateTabs(type); 14 | } 15 | 16 | function updateTabs(type) 17 | { 18 | for (var value in tabs) { 19 | var sNode = document.getElementById(tabs[value][0]); 20 | var spanNode = sNode.firstChild; 21 | if (value == type) { 22 | sNode.className = activeTableTab; 23 | spanNode.innerHTML = tabs[value][1]; 24 | } 25 | else { 26 | sNode.className = tableTab; 27 | spanNode.innerHTML = "" + tabs[value][1] + ""; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /doc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Overview List 7 | 8 | 9 | 10 | 11 | 12 | 13 | 23 |

 

24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/package-list: -------------------------------------------------------------------------------- 1 | brown.tracingplane 2 | brown.tracingplane.atomlayer 3 | brown.tracingplane.baggageprotocol 4 | brown.tracingplane.bdl 5 | brown.tracingplane.impl 6 | -------------------------------------------------------------------------------- /doc/script.js: -------------------------------------------------------------------------------- 1 | function show(type) 2 | { 3 | count = 0; 4 | for (var key in methods) { 5 | var row = document.getElementById(key); 6 | if ((methods[key] & type) != 0) { 7 | row.style.display = ''; 8 | row.className = (count++ % 2) ? rowColor : altColor; 9 | } 10 | else 11 | row.style.display = 'none'; 12 | } 13 | updateTabs(type); 14 | } 15 | 16 | function updateTabs(type) 17 | { 18 | for (var value in tabs) { 19 | var sNode = document.getElementById(tabs[value][0]); 20 | var spanNode = sNode.firstChild; 21 | if (value == type) { 22 | sNode.className = activeTableTab; 23 | spanNode.innerHTML = tabs[value][1]; 24 | } 25 | else { 26 | sNode.className = tableTab; 27 | spanNode.innerHTML = "" + tabs[value][1] + ""; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /doc/transit-layer-tutorial.md: -------------------------------------------------------------------------------- 1 | = Transit Layer Tutorial = 2 | 3 | TODO: this is not yet written. -------------------------------------------------------------------------------- /resources/log4j-surefire.properties: -------------------------------------------------------------------------------- 1 | # Root logger option 2 | log4j.rootLogger=WARN, stdout 3 | 4 | # Direct log messages to stdout 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.Target=System.out 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 9 | --------------------------------------------------------------------------------