idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
13,000 | private static SerializerFactory getInstance ( ) { if ( instance == null ) { String className = JacksonSerializerFactory . class . getName ( ) ; try { className = System . getProperty ( SERIALIZER_FACTORY_CLASS_NAME ) ; } catch ( Exception e ) { } if ( className != null ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Class < ? > clazz = loader . loadClass ( className ) ; instance = ( SerializerFactory ) clazz . newInstance ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Error instantiating serializer factory." ) ; } } else { instance = new JacksonSerializerFactory ( ) ; } } return instance ; } | Gets a singleton serializer factory instance . |
13,001 | public static Serializer getSerializer ( Class < ? > type ) { Class < ? > serializable = lookupSerializableType ( type ) ; Serializer serializer = serializers . get ( serializable ) ; if ( serializer == null ) { serializer = getInstance ( ) . createSerializer ( serializable ) ; serializers . put ( serializable , serializer ) ; } return serializer ; } | Gets a serializer instance . |
13,002 | private static Class < ? > lookupSerializableType ( Class < ? > type ) { Class < ? > serializableType = serializableTypes . get ( type ) ; if ( serializableType != null ) { return serializableType ; } serializableType = findSerializableType ( type ) ; if ( serializableType != null ) { serializableTypes . put ( type , serializableType ) ; return serializableType ; } return type ; } | Looks up the serializable type for the given type . |
13,003 | private static Class < ? > findSerializableType ( Class < ? > type ) { while ( type != null && type != Object . class ) { for ( Class < ? > iface : type . getInterfaces ( ) ) { if ( iface == JsonSerializable . class ) { return type ; } Class < ? > serializable = findSerializableType ( iface ) ; if ( serializable != null ) { return serializable ; } } type = type . getSuperclass ( ) ; } return null ; } | Iterates over the class hierarchy searching for the base serializable type . |
13,004 | public EventBusHookListener start ( Handler < AsyncResult < Void > > doneHandler ) { eventBus . registerHandler ( address , messageHandler , doneHandler ) ; return this ; } | Starts the hook listener registering a handler on the event bus . |
13,005 | private void createActiveNetwork ( final NetworkContext context , final Handler < AsyncResult < ActiveNetwork > > doneHandler ) { final DefaultActiveNetwork active = new DefaultActiveNetwork ( context . config ( ) , DefaultCluster . this ) ; vertx . eventBus ( ) . registerHandler ( String . format ( "%s.%s.change" , context . name ( ) , context . name ( ) ) , new Handler < Message < JsonObject > > ( ) { public void handle ( Message < JsonObject > message ) { String event = message . body ( ) . getString ( "type" ) ; if ( event . equals ( "change" ) && message . body ( ) . getString ( "value" ) != null ) { active . update ( Contexts . < NetworkContext > deserialize ( new JsonObject ( message . body ( ) . getString ( "value" ) ) ) ) ; } } } , new Handler < AsyncResult < Void > > ( ) { public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { new DefaultFutureResult < ActiveNetwork > ( new ClusterException ( result . cause ( ) ) ) . setHandler ( doneHandler ) ; } else { new DefaultFutureResult < ActiveNetwork > ( active ) . setHandler ( doneHandler ) ; } } } ) ; } | Creates and returns an active network . |
13,006 | @ SuppressWarnings ( "WeakerAccess" ) public SnackbarBuilder showCallback ( final SnackbarShowCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarShown ( Snackbar snackbar ) { callback . onSnackbarShown ( snackbar ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being shown . |
13,007 | @ SuppressWarnings ( "WeakerAccess" ) public SnackbarBuilder dismissCallback ( final SnackbarDismissCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarDismissed ( Snackbar snackbar , int dismissEvent ) { callback . onSnackbarDismissed ( snackbar , dismissEvent ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being dismissed through some means . |
13,008 | @ SuppressWarnings ( "WeakerAccess" ) public SnackbarBuilder actionDismissCallback ( final SnackbarActionDismissCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarActionPressed ( Snackbar snackbar ) { callback . onSnackbarActionPressed ( snackbar ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being dismissed due to the action being pressed . |
13,009 | @ SuppressWarnings ( "WeakerAccess" ) public SnackbarBuilder swipeDismissCallback ( final SnackbarSwipeDismissCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarSwiped ( Snackbar snackbar ) { callback . onSnackbarSwiped ( snackbar ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being dismissed due to being swiped away . |
13,010 | public SnackbarBuilder timeoutDismissCallback ( final SnackbarTimeoutDismissCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarTimedOut ( Snackbar snackbar ) { callback . onSnackbarTimedOut ( snackbar ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being dismissed due to a timeout . |
13,011 | @ SuppressWarnings ( "WeakerAccess" ) public SnackbarBuilder consecutiveDismissCallback ( final SnackbarConsecutiveDismissCallback callback ) { callbacks . add ( new SnackbarCallback ( ) { public void onSnackbarDismissedAfterAnotherShown ( Snackbar snackbar ) { callback . onSnackbarDismissedAfterAnotherShown ( snackbar ) ; } } ) ; return this ; } | Set the callback to be informed of the Snackbar being dismissed due to another Snackbar being shown . |
13,012 | public SnackbarWrapper buildWrapper ( ) { Snackbar snackbar = Snackbar . make ( parentView , message , duration ) ; SnackbarWrapper wrapper = new SnackbarWrapper ( snackbar ) . setAction ( actionText , sanitisedActionClickListener ( ) ) . setActionTextAllCaps ( actionAllCaps ) . addCallbacks ( callbacks ) . setIconMargin ( iconMargin ) ; if ( actionTextColor != 0 ) { wrapper . setActionTextColor ( actionTextColor ) ; } if ( messageTextColor != 0 ) { wrapper . setTextColor ( messageTextColor ) ; } if ( appendMessages != null ) { wrapper . appendMessage ( appendMessages ) ; } if ( backgroundColor != 0 ) { wrapper . setBackgroundColor ( backgroundColor ) ; } if ( icon != null ) { wrapper . setIcon ( icon ) ; } return wrapper ; } | Build a Snackbar using the options specified in the builder . Wrap this Snackbar into a SnackbarWrapper which allows further customisation . |
13,013 | private Map < Class < ? > , InterfaceInfo > getInterfaceInfoMap ( ) { if ( interfaceInfoMap == null ) { interfaceInfoMap = new HashMap < Class < ? > , InterfaceInfo > ( ) ; for ( final Class < ? > c : packageClasses ) { if ( INTERESTING_CLASSES . accept ( c ) ) { if ( ! interfaceInfoMap . containsKey ( c ) ) { interfaceInfoMap . put ( c , new InterfaceInfo ( c ) ) ; } } else { final Contract contract = c . getAnnotation ( Contract . class ) ; if ( contract != null ) { InterfaceInfo ii = interfaceInfoMap . get ( contract . value ( ) ) ; if ( ii == null ) { ii = new InterfaceInfo ( contract . value ( ) ) ; interfaceInfoMap . put ( contract . value ( ) , ii ) ; } ii . add ( c ) ; } } } } return interfaceInfoMap ; } | Get the interface info map . |
13,014 | public List < Throwable > getErrors ( ) { final List < Throwable > retval = new ArrayList < Throwable > ( ) ; for ( final TestInfo testInfo : contractTestMap . listTestInfo ( ) ) { retval . addAll ( testInfo . getErrors ( ) ) ; } return retval ; } | Get the set of errors encountered when discovering contract tests . This is a list of all errors for all tests . |
13,015 | public void update ( ByteBuffer buffer ) { length += buffer . remaining ( ) ; int position = buffer . position ( ) ; completeFinalBuffer ( buffer ) ; while ( buffer . remaining ( ) >= 64 ) { transform ( buffer ) ; } if ( buffer . remaining ( ) != 0 ) { finalBuffer . put ( buffer ) ; } buffer . position ( position ) ; } | Starts or continues a SHA - 1 message digest calculation . Only the remaining bytes of the given ByteBuffer are used . |
13,016 | public byte [ ] digest ( ) { byte [ ] result = new byte [ 20 ] ; finalBuffer . put ( ( byte ) 0x80 ) ; if ( finalBuffer . remaining ( ) < 8 ) { while ( finalBuffer . remaining ( ) > 0 ) { finalBuffer . put ( ( byte ) 0 ) ; } finalBuffer . position ( 0 ) ; transform ( finalBuffer ) ; finalBuffer . position ( 0 ) ; } while ( finalBuffer . remaining ( ) > 8 ) { finalBuffer . put ( ( byte ) 0 ) ; } finalBuffer . putLong ( length << 3 ) ; finalBuffer . position ( 0 ) ; transform ( finalBuffer ) ; finalBuffer . position ( 0 ) ; finalBuffer . putInt ( h0 ) ; finalBuffer . putInt ( h1 ) ; finalBuffer . putInt ( h2 ) ; finalBuffer . putInt ( h3 ) ; finalBuffer . putInt ( h4 ) ; finalBuffer . position ( 0 ) ; for ( int i = 0 ; i < 20 ; i ++ ) { result [ i ] = finalBuffer . get ( ) ; } return result ; } | Finishes the SHA - 1 message digest calculation . |
13,017 | public void restoreState ( ) { h0 = s0 ; h1 = s1 ; h2 = s2 ; h3 = s3 ; h4 = s4 ; length = saveLength ; finalBuffer . clear ( ) ; finalBuffer . put ( saveBuffer ) ; } | Restore the digest to its previously - saved state . |
13,018 | public void append ( String asciiString ) { if ( asciiString == null ) { throw new IllegalArgumentException ( "AsciiString must not be null" ) ; } ANTLRInputStream antlrInputStream = new ANTLRInputStream ( asciiString ) ; GDLLexer lexer = new GDLLexer ( antlrInputStream ) ; GDLParser parser = new GDLParser ( new CommonTokenStream ( lexer ) ) ; new ParseTreeWalker ( ) . walk ( loader , parser . database ( ) ) ; } | Append the given GDL string to the current database . |
13,019 | public Map < String , Graph > getGraphCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return loader . getGraphCache ( includeUserDefined , includeAutoGenerated ) ; } | Returns a cache that contains a mapping from variables to graph instances . |
13,020 | public Map < String , Vertex > getVertexCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return loader . getVertexCache ( includeUserDefined , includeAutoGenerated ) ; } | Returns a cache that contains a mapping from variables to vertex instances . |
13,021 | public Map < String , Edge > getEdgeCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return loader . getEdgeCache ( includeUserDefined , includeAutoGenerated ) ; } | Returns a cache that contains a mapping from variables to edge instances . |
13,022 | Optional < Predicate > getPredicates ( ) { return predicates != null ? Optional . of ( predicates ) : Optional . empty ( ) ; } | Returns the predicates defined by the query . |
13,023 | Map < String , Graph > getGraphCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return getCache ( userGraphCache , autoGraphCache , includeUserDefined , includeAutoGenerated ) ; } | Returns a cache containing a mapping from variables to graphs . |
13,024 | Map < String , Vertex > getVertexCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return getCache ( userVertexCache , autoVertexCache , includeUserDefined , includeAutoGenerated ) ; } | Returns a cache containing a mapping from variables to vertices . |
13,025 | Map < String , Edge > getEdgeCache ( boolean includeUserDefined , boolean includeAutoGenerated ) { return getCache ( userEdgeCache , autoEdgeCache , includeUserDefined , includeAutoGenerated ) ; } | Returns a cache containing a mapping from variables to edges . |
13,026 | public void enterGraph ( GDLParser . GraphContext graphContext ) { inGraph = true ; String variable = getVariable ( graphContext . header ( ) ) ; Graph g ; if ( variable != null && userGraphCache . containsKey ( variable ) ) { g = userGraphCache . get ( variable ) ; } else { g = initNewGraph ( graphContext ) ; if ( variable != null ) { userGraphCache . put ( variable , g ) ; } else { variable = String . format ( ANONYMOUS_GRAPH_VARIABLE , g . getId ( ) ) ; autoGraphCache . put ( variable , g ) ; } g . setVariable ( variable ) ; graphs . add ( g ) ; } currentGraphId = g . getId ( ) ; } | Called when parser enters a graph context . |
13,027 | public void exitQuery ( GDLParser . QueryContext ctx ) { for ( Vertex v : vertices ) { addPredicates ( Predicate . fromGraphElement ( v , getDefaultVertexLabel ( ) ) ) ; } for ( Edge e : edges ) { addPredicates ( Predicate . fromGraphElement ( e , getDefaultEdgeLabel ( ) ) ) ; } } | When leaving a query context its save to add the pattern predicates to the filters |
13,028 | public void enterVertex ( GDLParser . VertexContext vertexContext ) { String variable = getVariable ( vertexContext . header ( ) ) ; Vertex v ; if ( variable != null && userVertexCache . containsKey ( variable ) ) { v = userVertexCache . get ( variable ) ; } else { v = initNewVertex ( vertexContext ) ; if ( variable != null ) { userVertexCache . put ( variable , v ) ; } else { variable = String . format ( ANONYMOUS_VERTEX_VARIABLE , v . getId ( ) ) ; autoVertexCache . put ( variable , v ) ; } v . setVariable ( variable ) ; vertices . add ( v ) ; } updateGraphElement ( v ) ; setLastSeenVertex ( v ) ; updateLastSeenEdge ( v ) ; } | Called when parser enters a vertex context . |
13,029 | public void exitWhere ( GDLParser . WhereContext ctx ) { addPredicates ( Collections . singletonList ( currentPredicates . pop ( ) ) ) ; } | Called when the parser leaves a WHERE expression |
13,030 | public void exitNotExpression ( GDLParser . NotExpressionContext ctx ) { if ( ! ctx . NOT ( ) . isEmpty ( ) ) { Predicate not = new Not ( currentPredicates . pop ( ) ) ; currentPredicates . add ( not ) ; } } | Called when we leave an NotExpression . |
13,031 | private void processEdge ( GDLParser . EdgeBodyContext edgeBodyContext , boolean isIncoming ) { String variable = null ; Edge e ; if ( edgeBodyContext != null ) { variable = getVariable ( edgeBodyContext . header ( ) ) ; } if ( variable != null && userEdgeCache . containsKey ( variable ) ) { e = userEdgeCache . get ( variable ) ; } else { e = initNewEdge ( edgeBodyContext , isIncoming ) ; if ( variable != null ) { userEdgeCache . put ( variable , e ) ; } else { variable = String . format ( ANONYMOUS_EDGE_VARIABLE , e . getId ( ) ) ; autoEdgeCache . put ( variable , e ) ; } e . setVariable ( variable ) ; edges . add ( e ) ; } updateGraphElement ( e ) ; setLastSeenEdge ( e ) ; } | Processes incoming and outgoing edges . |
13,032 | private Graph initNewGraph ( GDLParser . GraphContext graphContext ) { Graph g = new Graph ( ) ; g . setId ( getNewGraphId ( ) ) ; List < String > labels = getLabels ( graphContext . header ( ) ) ; g . setLabels ( labels . isEmpty ( ) ? useDefaultGraphLabel ? Collections . singletonList ( defaultGraphLabel ) : Collections . emptyList ( ) : labels ) ; g . setProperties ( getProperties ( graphContext . properties ( ) ) ) ; return g ; } | Initializes a new graph from a given graph context . |
13,033 | private Vertex initNewVertex ( GDLParser . VertexContext vertexContext ) { Vertex v = new Vertex ( ) ; v . setId ( getNewVertexId ( ) ) ; List < String > labels = getLabels ( vertexContext . header ( ) ) ; v . setLabels ( labels . isEmpty ( ) ? useDefaultVertexLabel ? Collections . singletonList ( defaultVertexLabel ) : Collections . emptyList ( ) : labels ) ; v . setProperties ( getProperties ( vertexContext . properties ( ) ) ) ; return v ; } | Initializes a new vertex from a given vertex context . |
13,034 | private Edge initNewEdge ( GDLParser . EdgeBodyContext edgeBodyContext , boolean isIncoming ) { boolean hasBody = edgeBodyContext != null ; Edge e = new Edge ( ) ; e . setId ( getNewEdgeId ( ) ) ; e . setSourceVertexId ( getSourceVertexId ( isIncoming ) ) ; e . setTargetVertexId ( getTargetVertexId ( isIncoming ) ) ; if ( hasBody ) { List < String > labels = getLabels ( edgeBodyContext . header ( ) ) ; e . setLabels ( labels . isEmpty ( ) ? useDefaultEdgeLabel ? Collections . singletonList ( defaultEdgeLabel ) : Collections . emptyList ( ) : labels ) ; e . setProperties ( getProperties ( edgeBodyContext . properties ( ) ) ) ; int [ ] range = parseEdgeLengthContext ( edgeBodyContext . edgeLength ( ) ) ; e . setLowerBound ( range [ 0 ] ) ; e . setUpperBound ( range [ 1 ] ) ; } else { if ( useDefaultEdgeLabel ) { e . setLabel ( defaultEdgeLabel ) ; } else { e . setLabel ( null ) ; } } return e ; } | Initializes a new edge from the given edge body context . |
13,035 | private String getVariable ( GDLParser . HeaderContext header ) { if ( header != null && header . Identifier ( ) != null ) { return header . Identifier ( ) . getText ( ) ; } return null ; } | Returns the element variable from a given header context . |
13,036 | private List < String > getLabels ( GDLParser . HeaderContext header ) { if ( header != null && header . label ( ) != null ) { return header . label ( ) . stream ( ) . map ( RuleContext :: getText ) . map ( x -> x . substring ( 1 ) ) . collect ( Collectors . toList ( ) ) ; } return null ; } | Returns the element labels from a given header context . |
13,037 | private Map < String , Object > getProperties ( GDLParser . PropertiesContext propertiesContext ) { if ( propertiesContext != null ) { Map < String , Object > properties = new HashMap < > ( ) ; for ( GDLParser . PropertyContext property : propertiesContext . property ( ) ) { properties . put ( property . Identifier ( ) . getText ( ) , getPropertyValue ( property . literal ( ) ) ) ; } return properties ; } return Collections . emptyMap ( ) ; } | Returns the properties map from a given properties context . |
13,038 | private Object getPropertyValue ( GDLParser . LiteralContext literalContext ) { String text ; if ( literalContext . StringLiteral ( ) != null ) { return parseString ( literalContext . StringLiteral ( ) . getText ( ) ) ; } else if ( literalContext . BooleanLiteral ( ) != null ) { return Boolean . parseBoolean ( literalContext . BooleanLiteral ( ) . getText ( ) ) ; } else if ( literalContext . IntegerLiteral ( ) != null ) { text = literalContext . IntegerLiteral ( ) . getText ( ) . toLowerCase ( ) ; if ( text . endsWith ( "l" ) ) { return Long . parseLong ( text . substring ( 0 , text . length ( ) - 1 ) ) ; } return Integer . parseInt ( text ) ; } else if ( literalContext . FloatingPointLiteral ( ) != null ) { text = literalContext . FloatingPointLiteral ( ) . getText ( ) . toLowerCase ( ) ; if ( text . endsWith ( "f" ) ) { return Float . parseFloat ( text . substring ( 0 , text . length ( ) - 1 ) ) ; } else if ( text . endsWith ( "d" ) ) { return Double . parseDouble ( text . substring ( 0 , text . length ( ) - 1 ) ) ; } return Float . parseFloat ( text ) ; } return null ; } | Returns the corresponding value for a given literal . |
13,039 | private Comparison buildComparison ( GDLParser . ComparisonExpressionContext ctx ) { ComparableExpression lhs = extractComparableExpression ( ctx . comparisonElement ( 0 ) ) ; ComparableExpression rhs = extractComparableExpression ( ctx . comparisonElement ( 1 ) ) ; Comparator comp = Comparator . fromString ( ctx . ComparisonOP ( ) . getText ( ) ) ; return new Comparison ( lhs , comp , rhs ) ; } | Builds a Comparison filter operator from comparison context |
13,040 | private ComparableExpression extractComparableExpression ( GDLParser . ComparisonElementContext element ) { if ( element . literal ( ) != null ) { return new Literal ( getPropertyValue ( element . literal ( ) ) ) ; } else if ( element . propertyLookup ( ) != null ) { return buildPropertySelector ( element . propertyLookup ( ) ) ; } else { return new ElementSelector ( element . Identifier ( ) . getText ( ) ) ; } } | Extracts a ComparableExpression from comparissonElement |
13,041 | private PropertySelector buildPropertySelector ( GDLParser . PropertyLookupContext ctx ) { GraphElement element ; String identifier = ctx . Identifier ( 0 ) . getText ( ) ; String property = ctx . Identifier ( 1 ) . getText ( ) ; if ( userVertexCache . containsKey ( identifier ) ) { element = userVertexCache . get ( identifier ) ; } else if ( userEdgeCache . containsKey ( identifier ) ) { element = userEdgeCache . get ( identifier ) ; } else { throw new InvalidReferenceException ( identifier ) ; } return new PropertySelector ( element . getVariable ( ) , property ) ; } | Builds an property selector expression like alice . age |
13,042 | private void addPredicates ( List < Predicate > newPredicates ) { for ( Predicate newPredicate : newPredicates ) { if ( this . predicates == null ) { this . predicates = newPredicate ; } else { this . predicates = new And ( this . predicates , newPredicate ) ; } } } | Adds a list of predicates to the current predicates using AND conjunctions |
13,043 | private void updateLastSeenEdge ( Vertex v ) { Edge lastSeenEdge = getLastSeenEdge ( ) ; if ( lastSeenEdge != null ) { if ( lastSeenEdge . getSourceVertexId ( ) == null ) { lastSeenEdge . setSourceVertexId ( v . getId ( ) ) ; } else if ( lastSeenEdge . getTargetVertexId ( ) == null ) { lastSeenEdge . setTargetVertexId ( v . getId ( ) ) ; } } } | Updates the source or target vertex identifier of the last seen edge . |
13,044 | public static Method findAnnotatedGetter ( Class < ? > cls , Class < ? extends Annotation > class1 ) { for ( final Method m : cls . getDeclaredMethods ( ) ) { if ( m . getAnnotation ( class1 ) != null ) { if ( ! m . getReturnType ( ) . equals ( Void . TYPE ) && ! Modifier . isAbstract ( m . getModifiers ( ) ) && ( m . getParameterTypes ( ) . length == 0 ) && ( Modifier . isPublic ( m . getModifiers ( ) ) ) ) { return m ; } } } return null ; } | Find a getter with the specified annotation . getter must be annotated return a value not be abstract and not take any parameters and is public . |
13,045 | public void update ( byte [ ] data , int pos , int len ) { update ( ByteBuffer . wrap ( data , pos , len ) ) ; } | Start or continue a hash calculation with the given data starting at the given position for the given length . |
13,046 | public void setFilter ( String filter ) throws IllegalArgumentException { if ( StringUtils . isBlank ( filter ) ) { this . filter = ClassPathFilter . TRUE ; } else { this . filter = new Parser ( ) . parse ( filter ) ; } } | Set the class filter . Only classes that pass the filter will be included . By default the filter accepts all classes . Passing a null or null length string will result in all classes passing the test . |
13,047 | private ContractImpl getContractImpl ( final Class < ? > cls ) throws InitializationError { final ContractImpl impl = cls . getAnnotation ( ContractImpl . class ) ; if ( impl == null ) { throw new InitializationError ( "Classes annotated as @RunWith( ContractSuite ) [" + cls + "] must also be annotated with @ContractImpl" ) ; } return impl ; } | Get the ContractImpl annotation . Logs an error if the annotation is not found . |
13,048 | private List < Method > getExcludedMethods ( final Class < ? > cls ) { final List < Method > lst = new ArrayList < Method > ( ) ; for ( final ContractExclude exclude : cls . getAnnotationsByType ( ContractExclude . class ) ) { final Class < ? > clazz = exclude . value ( ) ; for ( final String mthdName : exclude . methods ( ) ) { try { lst . add ( clazz . getDeclaredMethod ( mthdName ) ) ; } catch ( NoSuchMethodException | SecurityException e ) { LOG . warn ( String . format ( "ContractExclude annotation on %s incorrect" , cls ) , e ) ; } } } return lst ; } | Get the ContractExclude annotation and extract the list of methods from it . |
13,049 | private List < Runner > addDynamicClasses ( final RunnerBuilder builder , final ContractTestMap contractTestMap , final Dynamic dynamic ) throws InitializationError { final Class < ? extends Dynamic > dynamicClass = dynamic . getClass ( ) ; final List < Runner > runners = new ArrayList < Runner > ( ) ; ContractImpl impl = getContractImpl ( dynamicClass ) ; if ( impl == null ) { return runners ; } final DynamicSuiteInfo dynamicSuiteInfo = new DynamicSuiteInfo ( dynamicClass , impl ) ; final Collection < Class < ? > > tests = dynamic . getSuiteClasses ( ) ; if ( ( tests == null ) || ( tests . size ( ) == 0 ) ) { dynamicSuiteInfo . addError ( new InitializationError ( "Dynamic suite did not return a list of classes to execute" ) ) ; runners . add ( new TestInfoErrorRunner ( dynamicClass , dynamicSuiteInfo ) ) ; } else { for ( final Class < ? > test : tests ) { final RunWith runwith = test . getAnnotation ( RunWith . class ) ; if ( ( runwith != null ) && runwith . value ( ) . equals ( ContractSuite . class ) ) { impl = getContractImpl ( test ) ; if ( impl != null ) { final DynamicTestInfo parentTestInfo = new DynamicTestInfo ( test , impl , dynamicSuiteInfo ) ; if ( ! parentTestInfo . hasErrors ( ) ) { addSpecifiedClasses ( runners , test , builder , contractTestMap , dynamic , parentTestInfo ) ; } if ( parentTestInfo . hasErrors ( ) ) { runners . add ( new TestInfoErrorRunner ( dynamicClass , parentTestInfo ) ) ; } } } else { try { runners . add ( builder . runnerForClass ( test ) ) ; } catch ( final Throwable t ) { throw new InitializationError ( t ) ; } } } } return runners ; } | Add dynamic classes to the suite . |
13,050 | private List < Runner > addAnnotatedClasses ( final Class < ? > baseClass , final RunnerBuilder builder , final ContractTestMap contractTestMap , final Object baseObj ) throws InitializationError { final List < Runner > runners = new ArrayList < Runner > ( ) ; final ContractImpl impl = getContractImpl ( baseClass ) ; if ( impl != null ) { TestInfo testInfo = contractTestMap . getInfoByTestClass ( impl . value ( ) ) ; if ( testInfo == null ) { testInfo = new SuiteInfo ( baseClass , impl ) ; contractTestMap . add ( testInfo ) ; } if ( ! testInfo . hasErrors ( ) ) { addSpecifiedClasses ( runners , baseClass , builder , contractTestMap , baseObj , testInfo ) ; } if ( testInfo . hasErrors ( ) ) { runners . add ( new TestInfoErrorRunner ( baseClass , testInfo ) ) ; } } return runners ; } | Add annotated classes to the test |
13,051 | private void addSpecifiedClasses ( final List < Runner > runners , final Class < ? > testClass , final RunnerBuilder builder , final ContractTestMap contractTestMap , final Object baseObj , final TestInfo parentTestInfo ) throws InitializationError { final Set < TestInfo > testClasses = new LinkedHashSet < TestInfo > ( ) ; final BaseClassRunner bcr = new BaseClassRunner ( testClass ) ; if ( bcr . computeTestMethods ( ) . size ( ) > 0 ) { runners . add ( bcr ) ; } final List < Method > excludeMethods = getExcludedMethods ( getTestClass ( ) . getJavaClass ( ) ) ; for ( final TestInfo testInfo : contractTestMap . getAnnotatedClasses ( testClasses , parentTestInfo ) ) { if ( ! Arrays . asList ( parentTestInfo . getSkipTests ( ) ) . contains ( testInfo . getClassUnderTest ( ) ) ) { if ( testInfo . getErrors ( ) . size ( ) > 0 ) { final TestInfoErrorRunner runner = new TestInfoErrorRunner ( testClass , testInfo ) ; runner . logErrors ( LOG ) ; runners . add ( runner ) ; } else { runners . add ( new ContractTestRunner ( baseObj , parentTestInfo , testInfo , excludeMethods ) ) ; } } } if ( runners . size ( ) == 0 ) { LOG . info ( "No tests for " + testClass ) ; } } | Adds the specified classes to to the test suite . |
13,052 | public static void saveAuthentication ( String url , boolean isCluster , final String authenticationToken , final boolean authenticationTokenIsPrivate , final String applicationKey , final int timeToLive , final String privateKey , final Map < String , ChannelPermissions > permissions , final OnRestWebserviceResponse onCompleted ) throws IOException , InvalidBalancerServerException , OrtcAuthenticationNotAuthorizedException { HashMap < String , LinkedList < ChannelPermissions > > permissionsMap = new HashMap < String , LinkedList < ChannelPermissions > > ( ) ; Set < String > channels = permissions . keySet ( ) ; for ( String channelName : channels ) { LinkedList < ChannelPermissions > channelPermissionList = new LinkedList < ChannelPermissions > ( ) ; channelPermissionList . add ( permissions . get ( channelName ) ) ; permissionsMap . put ( channelName , channelPermissionList ) ; } saveAuthentication ( url , isCluster , authenticationToken , authenticationTokenIsPrivate , applicationKey , timeToLive , privateKey , permissionsMap , onCompleted ) ; } | Asynchronously saves the authentication token channels permissions in the ORTC server . |
13,053 | public void runHandler ( OrtcClient sender , String channel , String message ) { this . runHandler ( sender , channel , message , false , null ) ; } | Fires the event handler that is associated the subscribed channel |
13,054 | public void publish ( final String channel , String message , final int ttl , OnPublishResult callback ) { final Pair < Boolean , String > sendValidation = isSendValid ( channel , message ) ; if ( sendValidation != null && sendValidation . first ) { try { final String messageId = Strings . randomString ( 8 ) ; final ArrayList < Pair < String , String > > messagesToSend = multiPartMessage ( message , messageId ) ; CountDownTimer ackTimeout = new CountDownTimer ( this . publishTimeout , 100 ) { public void onTick ( long millisUntilFinished ) { } public void onFinish ( ) { if ( pendingPublishMessages . containsKey ( messageId ) ) { String err = String . format ( "Message publish timeout after %l seconds" , publishTimeout ) ; if ( pendingPublishMessages != null && ( ( HashMap ) pendingPublishMessages . get ( messageId ) ) . containsKey ( "callback" ) ) { OnPublishResult callbackP = ( OnPublishResult ) ( ( HashMap ) pendingPublishMessages . get ( messageId ) ) . get ( "callback" ) ; callbackP . run ( err , null ) ; pendingPublishMessages . remove ( messageId ) ; } pendingPublishMessages . remove ( messageId ) ; } } } . start ( ) ; Map pendingMsg = new HashMap ( ) ; pendingMsg . put ( "totalNumOfParts" , messagesToSend . size ( ) ) ; pendingMsg . put ( "callback" , callback ) ; pendingMsg . put ( "timeout" , ackTimeout ) ; this . pendingPublishMessages . put ( messageId , pendingMsg ) ; if ( messagesToSend . size ( ) < 20 ) { for ( Pair < String , String > messageToSend : messagesToSend ) { publish ( channel , messageToSend . second , ttl , messageToSend . first , sendValidation . second ) ; } } else { partSendInterval = new CountDownTimer ( messagesToSend . size ( ) * 100 , 100 ) { int partsSent = 0 ; public void onTick ( long millisUntilFinished ) { int currentPart = partsSent + 1 ; if ( isConnected ) { Pair < String , String > messageToSend = messagesToSend . get ( currentPart ) ; publish ( channel , messageToSend . second , ttl , messageToSend . first , sendValidation . second ) ; partsSent ++ ; } } public void onFinish ( ) { } } . start ( ) ; } } catch ( IOException e ) { raiseOrtcEvent ( EventEnum . OnException , this , e ) ; } } } | Publish a message to a channel . |
13,055 | public void subscribeWithBuffer ( String channel , String subscriberId , final OnMessageWithBuffer onMessage ) { if ( subscriberId != null ) { HashMap options = new HashMap ( ) ; options . put ( "channel" , channel ) ; options . put ( "subscribeOnReconnected" , true ) ; options . put ( "subscriberId" , subscriberId ) ; this . subscribeWithOptions ( options , new OnMessageWithOptions ( ) { public void run ( OrtcClient sender , Map msgOptions ) { if ( msgOptions . containsKey ( "channel" ) && msgOptions . containsKey ( "message" ) ) { final String channel = ( String ) msgOptions . get ( "channel" ) ; final String message = ( String ) msgOptions . get ( "message" ) ; final String seqId = ( String ) msgOptions . get ( "seqId" ) ; onMessage . run ( sender , channel , seqId , message ) ; } } } ) ; } else { raiseOrtcEvent ( EventEnum . OnException , this , new OrtcGcmException ( "subscribeWithBuffer called with no subscriberId" ) ) ; } } | Subscribes to a channel to receive messages published to it . |
13,056 | public void subscribeWithNotifications ( String channel , boolean subscribeOnReconnect , OnMessage onMessage ) { _subscribeWithNotifications ( channel , subscribeOnReconnect , onMessage , false ) ; } | Subscribe the specified channel in order to receive messages in that channel with a support of Google Cloud Messaging . |
13,057 | public void unsubscribe ( String channel ) { ChannelSubscription subscribedChannel = subscribedChannels . get ( channel ) ; if ( isUnsubscribeValid ( channel , subscribedChannel ) ) { subscribedChannel . setSubscribeOnReconnected ( false ) ; unsubscribe ( channel , true , subscribedChannel . isWithNotification ( ) ) ; } } | Stop receiving messages in the specified channel |
13,058 | public void presence ( String channel , OnPresence callback ) throws OrtcNotConnectedException { if ( ! this . isConnected ) { throw new OrtcNotConnectedException ( ) ; } else { String presenceUrl = this . isCluster ? this . clusterUrl : this . url ; Ortc . presence ( presenceUrl , this . isCluster , this . applicationKey , this . authenticationToken , channel , callback ) ; } } | Gets the subscriptions in the specified channel and if active the first 100 unique metadata . |
13,059 | public void enablePresence ( String privateKey , String channel , Boolean metadata , OnEnablePresence callback ) throws OrtcNotConnectedException { if ( ! this . isConnected ) { throw new OrtcNotConnectedException ( ) ; } else { String presenceUrl = this . isCluster ? this . clusterUrl : this . url ; Ortc . enablePresence ( presenceUrl , this . isCluster , this . applicationKey , privateKey , channel , metadata , callback ) ; } } | Enables presence for the specified channel with first 100 unique metadata if metadata is set to true . |
13,060 | protected String determineDatabaseType ( ) throws HandlerException { String dbName = null ; try ( Connection conn = getConnection ( ) ) { dbName = conn . getMetaData ( ) . getDatabaseProductName ( ) ; } catch ( SQLException e ) { throw new HandlerException ( "Exception occured while getting DB Name" , DatabaseAuditHandler . class , e ) ; } return dbName ; } | Determine database type using database metadata product name . |
13,061 | protected boolean isOracleDatabase ( ) throws HandlerException { String dbName = determineDatabaseType ( ) ; if ( dbName == null ) { return false ; } return "Oracle" . equalsIgnoreCase ( dbName ) ; } | Checks if is oracle database . |
13,062 | protected boolean isHSQLDatabase ( ) throws HandlerException { String dbName = determineDatabaseType ( ) ; if ( dbName == null ) { return false ; } return "HSQL Database Engine" . equalsIgnoreCase ( dbName ) ; } | Checks if is HSQL database . |
13,063 | protected boolean isMySQLDatabase ( ) throws HandlerException { String dbName = determineDatabaseType ( ) ; if ( dbName == null ) { return false ; } return "MySQL" . equalsIgnoreCase ( dbName ) ; } | Checks if the database is MySQL . |
13,064 | protected boolean isSQLServerDatabase ( ) throws HandlerException { String dbName = determineDatabaseType ( ) ; if ( dbName == null ) { return false ; } return "Microsoft SQL Server" . equalsIgnoreCase ( dbName ) ; } | Checks if is SQLServer database . |
13,065 | protected static void getRegistrationId ( OrtcClient ortcClient ) { if ( checkPlayServices ( ortcClient ) ) { gcm = GoogleCloudMessaging . getInstance ( ortcClient . appContext ) ; if ( ortcClient . registrationId . isEmpty ( ) ) { String regid = getRegistrationId ( ortcClient . appContext ) ; ortcClient . registrationId = regid ; if ( regid . isEmpty ( ) ) { registerInBackground ( ortcClient ) ; } } } else { ortcClient . raiseOrtcEvent ( EventEnum . OnException , ortcClient , new OrtcGcmException ( "No valid Google Play Services APK found." ) ) ; } } | private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000 ; |
13,066 | Connection getDataSourceConnection ( ) { Connection connection = null ; try { connection = dataSource . getConnection ( ) ; } catch ( SQLException ex ) { throw new InitializationException ( "Could not obtain the db connection: Cannot get connection" , ex ) ; } return connection ; } | Gets the data source connection . |
13,067 | void init ( ) { if ( dataSource == null ) { if ( connectionType . equals ( ConnectionType . POOLED ) ) { HikariConfig config = new HikariConfig ( ) ; config . setMaximumPoolSize ( maximumPoolSize ) ; config . setDataSourceClassName ( dataSourceClass ) ; config . addDataSourceProperty ( "url" , url ) ; config . addDataSourceProperty ( "user" , user ) ; config . addDataSourceProperty ( "password" , password ) ; config . setPoolName ( CONNECTION_POOL_NAME ) ; config . setAutoCommit ( autoCommit ) ; config . setMaximumPoolSize ( maximumPoolSize ) ; if ( connectionTimeout != null ) { config . setConnectionTimeout ( connectionTimeout ) ; } if ( idleTimeout != null ) { config . setIdleTimeout ( idleTimeout ) ; } if ( maxLifetime != null ) { config . setMaxLifetime ( maxLifetime ) ; } if ( minimumIdle != null ) { config . setMinimumIdle ( minimumIdle ) ; } ds = new HikariDataSource ( config ) ; dataSource = ds ; } else if ( connectionType . equals ( ConnectionType . JNDI ) ) { if ( null == jndiDataSource ) { throw new InitializationException ( "Could not obtain the db connection: jndi data source is null" ) ; } String DATASOURCE_CONTEXT = jndiDataSource ; try { Context initialContext = new InitialContext ( ) ; dataSource = ( DataSource ) initialContext . lookup ( DATASOURCE_CONTEXT ) ; if ( dataSource == null ) { Log . error ( "Failed to lookup datasource." ) ; throw new InitializationException ( "Could not obtain the db connection: Failed to lookup datasource: " + jndiDataSource ) ; } } catch ( NamingException ex ) { throw new InitializationException ( "Could not obtain the db connection: jndi lookup failed" , ex ) ; } } } } | initialize connection factory . This will created the necessary connection pools and jndi lookups in advance . |
13,068 | public static String getDBName ( String userName ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( EMBEDED_DB_NAME ) ; buffer . append ( "@" ) ; buffer . append ( userName ) ; return buffer . toString ( ) ; } | Gets the dB name . |
13,069 | public static String checkNotEmpty ( String str , String message ) { if ( checkNotNull ( str ) . isEmpty ( ) ) { throw new IllegalArgumentException ( message ) ; } return str ; } | Throws a IllegalArgumentException if given String is empty |
13,070 | public void init ( ) throws InitializationException { if ( null == embedded || "true" . equalsIgnoreCase ( embedded ) ) { Log . warn ( "Audit4j Database Handler runs on embedded mode. See " + ErrorGuide . ERROR_URL + "embeddeddb for further details." ) ; server = HSQLEmbededDBServer . getInstance ( ) ; db_driver = server . getDriver ( ) ; db_url = server . getNetworkProtocol ( ) + ":file:audit4jdb" ; if ( db_user == null ) { db_user = Utils . EMBEDED_DB_USER ; } if ( db_password == null ) { db_password = Utils . EMBEDED_DB_PASSWORD ; } server . setUname ( db_user ) ; server . setPassword ( db_password ) ; server . start ( ) ; } factory = ConnectionFactory . getInstance ( ) ; factory . setDataSource ( dataSource ) ; factory . setDriver ( getDb_driver ( ) ) ; factory . setUrl ( getDb_url ( ) ) ; factory . setUser ( getDb_user ( ) ) ; factory . setPassword ( getDb_password ( ) ) ; factory . setDataSourceClass ( db_datasourceClass ) ; factory . setAutoCommit ( db_pool_autoCommit ) ; if ( db_pool_connectionTimeout != null ) { factory . setConnectionTimeout ( db_pool_connectionTimeout ) ; } if ( db_pool_idleTimeout != null ) { factory . setIdleTimeout ( db_pool_idleTimeout ) ; } if ( db_pool_maximumPoolSize != null ) { factory . setMaximumPoolSize ( db_pool_maximumPoolSize ) ; } if ( db_pool_maxLifetime != null ) { factory . setMaxLifetime ( db_pool_maxLifetime ) ; } if ( db_pool_minimumIdle != null ) { factory . setMinimumIdle ( db_pool_minimumIdle ) ; } if ( getDb_connection_type ( ) != null && getDb_connection_type ( ) . equals ( POOLED_CONNECTION ) ) { factory . setConnectionType ( ConnectionType . POOLED ) ; } else if ( getDb_connection_type ( ) != null && getDb_connection_type ( ) . equals ( JNDI_CONNECTION ) ) { factory . setConnectionType ( ConnectionType . JNDI ) ; factory . setJndiDataSource ( getDb_jndi_datasource ( ) ) ; } else { factory . setConnectionType ( ConnectionType . SINGLE ) ; } factory . init ( ) ; try { getDaoForTable ( default_table_name ) ; } catch ( HandlerException e ) { throw new InitializationException ( "Unable to create tables" , e ) ; } } | Initialize database handler . |
13,071 | private String generateTableName ( String repository ) { if ( table_prefix == null ) { return repository + "_" + table_suffix ; } return table_prefix + "_" + repository + "_" + table_suffix ; } | Generate table name . |
13,072 | public static EJBContainer createEJBContainer ( Map < ? , ? > properties ) throws EJBException { for ( EJBContainerProvider factory : factories ) { EJBContainer container = factory . createEJBContainer ( properties ) ; if ( container != null ) return container ; } throw new EJBException ( "Unable to instantiate container with factories " + factories ) ; } | Create and initialize an embeddable EJB container with an set of configuration properties and names of modules to be initialized . |
13,073 | public static String extractClassNameFromFile ( final File parentDirectory , final File classFile ) throws IOException { if ( null == classFile ) { return null ; } final String qualifiedFileName = parentDirectory != null ? classFile . getCanonicalPath ( ) . substring ( parentDirectory . getCanonicalPath ( ) . length ( ) + 1 ) : classFile . getCanonicalPath ( ) ; return removeExtension ( qualifiedFileName . replace ( File . separator , "." ) ) ; } | Remove parent directory from file name and replace directory separator with dots . |
13,074 | public static Iterator < String > iterateClassnames ( final File parentDirectory , final File ... classFiles ) { return iterateClassnames ( parentDirectory , Arrays . asList ( classFiles ) . iterator ( ) ) ; } | Iterate over the class files and remove the parent directory from file name and replace directory separator with dots . |
13,075 | public void setProperties ( final Properties properties ) { this . properties = ( null == properties ) ? new Properties ( ) : ( Properties ) properties . clone ( ) ; } | Sets the optional settings for the transformer class . |
13,076 | public LocalDistribution getDistribution ( WrapperConfiguration configuration ) { String baseName = getDistName ( configuration . getDistribution ( ) ) ; String distName = removeExtension ( baseName ) ; String rootDirName = rootDirName ( distName , configuration ) ; String distDirPathName = configuration . getDistributionPath ( ) + "/" + rootDirName ; File distDir = new File ( getBaseDir ( configuration . getDistributionBase ( ) ) , distDirPathName ) ; String distZipFilename = configuration . getZipPath ( ) + "/" + rootDirName + "/" + baseName ; File distZip = new File ( getBaseDir ( configuration . getZipBase ( ) ) , distZipFilename ) ; return new LocalDistribution ( distDir , distZip ) ; } | Determines the local locations for the distribution to use given the supplied configuration . |
13,077 | protected String evaluateOutputDirectory ( final String outputDir , final String inputDir ) { return outputDir != null && ! outputDir . trim ( ) . isEmpty ( ) ? outputDir : inputDir . trim ( ) ; } | Evaluates and returns the output directory . |
13,078 | @ SuppressWarnings ( "unchecked" ) public A replace ( Property property ) { Data data = getData ( ) ; Data replaced = data . replace ( property ) ; if ( ! replaced . isEmpty ( ) ) { return copy ( delegate . put ( "data" , Property . toArrayNode ( replaced ) ) ) ; } return ( A ) this ; } | Replaces all properties with the same name as the supplied property |
13,079 | public Data replace ( Iterable < Property > replacement ) { if ( Iterables . isEmpty ( replacement ) ) { return this ; } Map < String , Property > map = getDataAsMap ( replacement ) ; List < Property > props = this . stream ( ) . map ( f -> map . getOrDefault ( f . getName ( ) , f ) ) . collect ( Collectors . toList ( ) ) ; return new Data ( props ) ; } | Replaces all properties with the same name as the supplied properties . |
13,080 | public void materializeHelper ( Materializer maker ) throws IOException { if ( ! materialized ) { ReaderWriterProfiler . start ( ReaderWriterProfiler . Counter . DECODING_TIME ) ; try { maker . materialize ( treeReader , currentRow ) ; materialized = true ; writableCreated = false ; nextIsNull = false ; nextIsNullSet = true ; } catch ( ValueNotPresentException e ) { materialized = true ; writableCreated = true ; nextIsNull = true ; nextIsNullSet = true ; throw new IOException ( "Cannot materialize primitive: value not present" ) ; } ReaderWriterProfiler . end ( ReaderWriterProfiler . Counter . DECODING_TIME ) ; } else if ( nextIsNull ) { throw new IOException ( "Cannot materialize primitive: value not present." ) ; } } | A Helper to materialize primitive data types |
13,081 | void broadcast ( ClusterConfiguration config ) { Message vote = voteInfo . toMessage ( ) ; for ( String server : config . getPeers ( ) ) { this . transport . send ( server , vote ) ; } } | Broadcasts its vote to all the peers in current configuration . |
13,082 | public static ZabMessage . Zxid toProtoZxid ( Zxid zxid ) { ZabMessage . Zxid z = ZabMessage . Zxid . newBuilder ( ) . setEpoch ( zxid . getEpoch ( ) ) . setXid ( zxid . getXid ( ) ) . build ( ) ; return z ; } | Converts Zxid object to protobuf Zxid object . |
13,083 | public static Zxid fromProtoZxid ( ZabMessage . Zxid zxid ) { return new Zxid ( zxid . getEpoch ( ) , zxid . getXid ( ) ) ; } | Converts protobuf Zxid object to Zxid object . |
13,084 | public static Transaction fromProposal ( Proposal prop ) { Zxid zxid = fromProtoZxid ( prop . getZxid ( ) ) ; ByteBuffer buffer = prop . getBody ( ) . asReadOnlyByteBuffer ( ) ; return new Transaction ( zxid , prop . getType ( ) . getNumber ( ) , buffer ) ; } | Converts protobuf Proposal object to Transaction object . |
13,085 | public static Proposal fromTransaction ( Transaction txn ) { ZabMessage . Zxid zxid = toProtoZxid ( txn . getZxid ( ) ) ; ByteString bs = ByteString . copyFrom ( txn . getBody ( ) ) ; return Proposal . newBuilder ( ) . setZxid ( zxid ) . setBody ( bs ) . setType ( ProposalType . values ( ) [ txn . getType ( ) ] ) . build ( ) ; } | Converts Transaction object to protobuf Proposal object . |
13,086 | public static Message buildProposedEpoch ( long proposedEpoch , long acknowledgedEpoch , ClusterConfiguration config , int syncTimeoutMs ) { ZabMessage . Zxid version = toProtoZxid ( config . getVersion ( ) ) ; ZabMessage . ClusterConfiguration zCnf = ZabMessage . ClusterConfiguration . newBuilder ( ) . setVersion ( version ) . addAllServers ( config . getPeers ( ) ) . build ( ) ; ProposedEpoch pEpoch = ProposedEpoch . newBuilder ( ) . setProposedEpoch ( proposedEpoch ) . setCurrentEpoch ( acknowledgedEpoch ) . setConfig ( zCnf ) . setSyncTimeout ( syncTimeoutMs ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . PROPOSED_EPOCH ) . setProposedEpoch ( pEpoch ) . build ( ) ; } | Creates CEPOCH message . |
13,087 | public static Message buildNewEpochMessage ( long epoch , int syncTimeoutMs ) { NewEpoch nEpoch = NewEpoch . newBuilder ( ) . setNewEpoch ( epoch ) . setSyncTimeout ( syncTimeoutMs ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . NEW_EPOCH ) . setNewEpoch ( nEpoch ) . build ( ) ; } | Creates a NEW_EPOCH message . |
13,088 | public static Message buildAckEpoch ( long epoch , Zxid lastZxid ) { ZabMessage . Zxid zxid = toProtoZxid ( lastZxid ) ; AckEpoch ackEpoch = AckEpoch . newBuilder ( ) . setAcknowledgedEpoch ( epoch ) . setLastZxid ( zxid ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . ACK_EPOCH ) . setAckEpoch ( ackEpoch ) . build ( ) ; } | Creates a ACK_EPOCH message . |
13,089 | public static Message buildInvalidMessage ( byte [ ] content ) { InvalidMessage msg = InvalidMessage . newBuilder ( ) . setReceivedBytes ( ByteString . copyFrom ( content ) ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . INVALID_MESSAGE ) . setInvalid ( msg ) . build ( ) ; } | Creates an INVALID message . This message will not be transmitted among workers . It s created when protobuf fails to parse the byte buffer . |
13,090 | public static Message buildPullTxnReq ( Zxid lastZxid ) { ZabMessage . Zxid zxid = toProtoZxid ( lastZxid ) ; PullTxnReq req = PullTxnReq . newBuilder ( ) . setLastZxid ( zxid ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . PULL_TXN_REQ ) . setPullTxnReq ( req ) . build ( ) ; } | Creates a PULL_TXN_REQ message to ask follower sync its history to leader . |
13,091 | public static Message buildProposal ( Transaction txn ) { ZabMessage . Zxid zxid = toProtoZxid ( txn . getZxid ( ) ) ; Proposal prop = Proposal . newBuilder ( ) . setZxid ( zxid ) . setBody ( ByteString . copyFrom ( txn . getBody ( ) ) ) . setType ( ProposalType . values ( ) [ txn . getType ( ) ] ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . PROPOSAL ) . setProposal ( prop ) . build ( ) ; } | Creates a PROPOSAL message . |
13,092 | public static Message buildDiff ( Zxid lastZxid ) { ZabMessage . Zxid lz = toProtoZxid ( lastZxid ) ; Diff diff = Diff . newBuilder ( ) . setLastZxid ( lz ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . DIFF ) . setDiff ( diff ) . build ( ) ; } | Creates a DIFF message . |
13,093 | public static Message buildTruncate ( Zxid lastPrefixZxid , Zxid lastZxid ) { ZabMessage . Zxid lpz = toProtoZxid ( lastPrefixZxid ) ; ZabMessage . Zxid lz = toProtoZxid ( lastZxid ) ; Truncate trunc = Truncate . newBuilder ( ) . setLastPrefixZxid ( lpz ) . setLastZxid ( lz ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . TRUNCATE ) . setTruncate ( trunc ) . build ( ) ; } | Creates a TRUNCATE message . |
13,094 | public static Message buildNewLeader ( long epoch ) { NewLeader nl = NewLeader . newBuilder ( ) . setEpoch ( epoch ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . NEW_LEADER ) . setNewLeader ( nl ) . build ( ) ; } | Creates a NEW_LEADER message . |
13,095 | public static Message buildAck ( Zxid zxid ) { ZabMessage . Zxid zzxid = toProtoZxid ( zxid ) ; Ack ack = Ack . newBuilder ( ) . setZxid ( zzxid ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . ACK ) . setAck ( ack ) . build ( ) ; } | Creates a ACK message . |
13,096 | public static Message buildRequest ( ByteBuffer request ) { Request req = Request . newBuilder ( ) . setRequest ( ByteString . copyFrom ( request ) ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . REQUEST ) . setRequest ( req ) . build ( ) ; } | Creates a REQUEST message . |
13,097 | public static Message buildCommit ( Zxid zxid ) { ZabMessage . Zxid cZxid = toProtoZxid ( zxid ) ; Commit commit = Commit . newBuilder ( ) . setZxid ( cZxid ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . COMMIT ) . setCommit ( commit ) . build ( ) ; } | Creates a COMMIT message . |
13,098 | public static Message buildHandshake ( String nodeId ) { Handshake handshake = Handshake . newBuilder ( ) . setNodeId ( nodeId ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . HANDSHAKE ) . setHandshake ( handshake ) . build ( ) ; } | Creates a HANDSHAKE message . |
13,099 | public static Message buildDisconnected ( String serverId ) { Disconnected dis = Disconnected . newBuilder ( ) . setServerId ( serverId ) . build ( ) ; return Message . newBuilder ( ) . setType ( MessageType . DISCONNECTED ) . setDisconnected ( dis ) . build ( ) ; } | Creates a DISCONNECTED message . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.