idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
4,700 | @ SuppressWarnings ( "unchecked" ) protected void preLoad ( FFMQJNDIContext context ) throws NamingException { context . bind ( FFMQConstants . JNDI_CONNECTION_FACTORY_NAME , new FFMQConnectionFactory ( ( Hashtable < String , Object > ) context . getEnvironment ( ) ) ) ; context . bind ( FFMQConstants . JNDI_QUEUE_CONNECTION_FACTORY_NAME , new FFMQQueueConnectionFactory ( ( Hashtable < String , Object > ) context . getEnvironment ( ) ) ) ; context . bind ( FFMQConstants . JNDI_TOPIC_CONNECTION_FACTORY_NAME , new FFMQTopicConnectionFactory ( ( Hashtable < String , Object > ) context . getEnvironment ( ) ) ) ; } | Preload the context with factories |
4,701 | public static Map < HeaderName < ? > , Object > copyFromStream ( final Stream < Map . Entry < HeaderName < ? > , Object > > stream ) { Map < HeaderName < ? > , Object > headerMap ; if ( stream == null ) { headerMap = new HashMap < > ( ) ; } else { headerMap = stream . collect ( Collectors . toMap ( Map . Entry :: getKey , Map . Entry :: getValue ) ) ; } return headerMap ; } | Creates a new map by picking all header entries from the provided stream . |
4,702 | public void setPreferredOrder ( final Collection < Class < ? extends Saga > > preferredOrder ) { checkNotNull ( preferredOrder , "Preferred order list may not be null. Empty is allowed." ) ; cacheLoader . setPreferredOrder ( preferredOrder ) ; sagasForMessageType . invalidateAll ( ) ; } | Sets the handlers that should be executed first . |
4,703 | private Multimap < Class , SagaType > initializeMessageMappings ( final Map < Class < ? extends Saga > , SagaHandlersMap > handlersMap ) { Multimap < Class , SagaType > scannedTypes = LinkedListMultimap . create ( ) ; for ( Map . Entry < Class < ? extends Saga > , SagaHandlersMap > entry : handlersMap . entrySet ( ) ) { Class < ? extends Saga > sagaClass = entry . getKey ( ) ; Collection < MessageHandler > sagaHandlers = entry . getValue ( ) . messageHandlers ( ) ; for ( MessageHandler handler : sagaHandlers ) { if ( handler . getStartsSaga ( ) ) { scannedTypes . put ( handler . getMessageType ( ) , SagaType . startsNewSaga ( sagaClass ) ) ; } else { scannedTypes . put ( handler . getMessageType ( ) , SagaType . continueSaga ( sagaClass ) ) ; } } } return scannedTypes ; } | Populate internal map to translate between incoming message event type and saga type . |
4,704 | public boolean supportDeliveryMode ( int deliveryMode ) { switch ( deliveryMode ) { case DeliveryMode . PERSISTENT : return initialBlockCount > 0 ; case DeliveryMode . NON_PERSISTENT : return maxNonPersistentMessages > 0 ; default : throw new IllegalArgumentException ( "Invalid delivery mode : " + deliveryMode ) ; } } | Test if this topic definition supports the given delivery mode |
4,705 | private Collection < Class < ? extends Saga > > removeAbstractTypes ( final Collection < Class < ? extends Saga > > foundTypes ) { Collection < Class < ? extends Saga > > sagaTypes = new ArrayList < > ( ) ; for ( Class < ? extends Saga > entryType : foundTypes ) { if ( ! Modifier . isAbstract ( entryType . getModifiers ( ) ) ) { sagaTypes . add ( entryType ) ; } } return sagaTypes ; } | Creates a new collection with abstract types which can not be instantiated . |
4,706 | public void writeNullableUTF ( String str ) { if ( str == null ) write ( NULL_VALUE ) ; else { write ( NOT_NULL_VALUE ) ; writeUTF ( str ) ; } } | Write a string or null value to the stream |
4,707 | public final void ensureCapacity ( int targetCapacity ) { if ( targetCapacity > capacity ) { int newLength = Math . max ( capacity << 1 , targetCapacity ) ; byte [ ] copy = new byte [ newLength ] ; System . arraycopy ( buf , 0 , copy , 0 , capacity ) ; buf = copy ; capacity = newLength ; } } | Ensure that the buffer internal capacity is at least targetCapacity |
4,708 | public void writeNullableByteArray ( byte [ ] value ) { if ( value == null ) write ( NULL_VALUE ) ; else { write ( NOT_NULL_VALUE ) ; writeInt ( value . length ) ; write ( value ) ; } } | Write a nullable byte array to the stream |
4,709 | public void writeGeneric ( Object value ) { if ( value == null ) write ( NULL_VALUE ) ; else { if ( value instanceof String ) { writeByte ( TYPE_STRING ) ; writeUTF ( ( String ) value ) ; } else if ( value instanceof Boolean ) { writeByte ( TYPE_BOOLEAN ) ; writeBoolean ( ( ( Boolean ) value ) . booleanValue ( ) ) ; } else if ( value instanceof Byte ) { writeByte ( TYPE_BYTE ) ; writeByte ( ( ( Byte ) value ) . byteValue ( ) ) ; } else if ( value instanceof Short ) { writeByte ( TYPE_SHORT ) ; writeShort ( ( ( Short ) value ) . shortValue ( ) ) ; } else if ( value instanceof Integer ) { writeByte ( TYPE_INT ) ; writeInt ( ( ( Integer ) value ) . intValue ( ) ) ; } else if ( value instanceof Long ) { writeByte ( TYPE_LONG ) ; writeLong ( ( ( Long ) value ) . longValue ( ) ) ; } else if ( value instanceof Float ) { writeByte ( TYPE_FLOAT ) ; writeFloat ( ( ( Float ) value ) . floatValue ( ) ) ; } else if ( value instanceof Double ) { writeByte ( TYPE_DOUBLE ) ; writeDouble ( ( ( Double ) value ) . doubleValue ( ) ) ; } else if ( value instanceof byte [ ] ) { writeByte ( TYPE_BYTEARRAY ) ; writeByteArray ( ( byte [ ] ) value ) ; } else if ( value instanceof Character ) { writeByte ( TYPE_CHARACTER ) ; writeChar ( ( ( Character ) value ) . charValue ( ) ) ; } else throw new IllegalArgumentException ( "Unsupported type : " + value . getClass ( ) . getName ( ) ) ; } } | Write a generic type to the stream |
4,710 | public static MessageHandler reflectionInvokedHandler ( final Class < ? > messageType , final Method methodToInvoke , final boolean startsSaga ) { return new MessageHandler ( messageType , methodToInvoke , startsSaga ) ; } | Creates new handler with the reflection information about the method to call . |
4,711 | private void timeoutExpired ( final Timeout timeout , final TimeoutContext context ) { try { removeExpiredTimeout ( timeout ) ; for ( TimeoutExpired callback : callbacks ) { if ( callback instanceof TimeoutExpirationCallback ) { ( ( TimeoutExpirationCallback ) callback ) . expired ( timeout , context ) ; } else { callback . expired ( timeout ) ; } } } catch ( Exception ex ) { LOG . error ( "Error handling timeout." , ex ) ; } } | Called by timeout task once timeout has expired . |
4,712 | private void closeRemainingEnumerations ( ) { List < AbstractQueueBrowserEnumeration > enumsToClose = new Vector < > ( ) ; synchronized ( enumMap ) { enumsToClose . addAll ( enumMap . values ( ) ) ; for ( int n = 0 ; n < enumsToClose . size ( ) ; n ++ ) { AbstractQueueBrowserEnumeration queueBrowserEnum = enumsToClose . get ( n ) ; log . debug ( "Auto-closing unclosed queue browser enumeration : " + queueBrowserEnum ) ; try { queueBrowserEnum . close ( ) ; } catch ( Exception e ) { log . error ( "Could not close queue browser enumeration " + queueBrowserEnum , e ) ; } } } } | Close remaining browser enumerations |
4,713 | public static void serializeTo ( Destination destination , RawDataBuffer out ) { try { if ( destination == null ) { out . writeByte ( NO_DESTINATION ) ; } else if ( destination instanceof Queue ) { out . writeByte ( TYPE_QUEUE ) ; out . writeUTF ( ( ( Queue ) destination ) . getQueueName ( ) ) ; } else if ( destination instanceof Topic ) { out . writeByte ( TYPE_TOPIC ) ; out . writeUTF ( ( ( Topic ) destination ) . getTopicName ( ) ) ; } else throw new IllegalArgumentException ( "Unsupported destination : " + destination ) ; } catch ( JMSException e ) { throw new IllegalArgumentException ( "Cannot serialize destination : " + e . getMessage ( ) ) ; } } | Serialize a destination to the given stream |
4,714 | public static DestinationRef unserializeFrom ( RawDataBuffer in ) { int type = in . readByte ( ) ; if ( type == NO_DESTINATION ) return null ; String destinationName = in . readUTF ( ) ; switch ( type ) { case TYPE_QUEUE : return new QueueRef ( destinationName ) ; case TYPE_TOPIC : return new TopicRef ( destinationName ) ; default : throw new IllegalArgumentException ( "Unsupported destination type : " + type ) ; } } | Unserialize a destination from the given stream |
4,715 | private Collection < SagaType > prepareTypesList ( ) { Collection < SagaType > sagaTypes = new ArrayList < > ( ) ; Collection < SagaType > sagasToExecute = typesForMessageMapper . getSagasForMessageType ( Timeout . class ) ; for ( SagaType type : sagasToExecute ) { if ( type . isStartingNewSaga ( ) ) { sagaTypes . add ( type ) ; } } return sagaTypes ; } | Timeouts are special . They do not need an instance key to be found . However there may be other starting sagas that want to handle timeouts of other saga instances . |
4,716 | public void unregisterServerSocketHandler ( NIOServerSocketHandler serverHandler ) { if ( pendingAcceptHandlers . remove ( serverHandler ) ) return ; if ( serverHandlers . remove ( serverHandler ) ) { closeSocketChannel ( serverHandler . getServerSocketChannel ( ) , selector ) ; wakeUpAndWait ( ) ; } } | Unregister a new server socket handler |
4,717 | protected final byte [ ] serializeAllocationBlock ( int blockIndex ) { byte [ ] allocationBlock = new byte [ AT_BLOCK_SIZE ] ; allocationBlock [ AB_FLAGS_OFFSET ] = flags [ blockIndex ] ; allocationBlock [ AB_ALLOCSIZE_OFFSET ] = ( byte ) ( ( allocatedSize [ blockIndex ] >>> 24 ) & 0xFF ) ; allocationBlock [ AB_ALLOCSIZE_OFFSET + 1 ] = ( byte ) ( ( allocatedSize [ blockIndex ] >>> 16 ) & 0xFF ) ; allocationBlock [ AB_ALLOCSIZE_OFFSET + 2 ] = ( byte ) ( ( allocatedSize [ blockIndex ] >>> 8 ) & 0xFF ) ; allocationBlock [ AB_ALLOCSIZE_OFFSET + 3 ] = ( byte ) ( ( allocatedSize [ blockIndex ] >>> 0 ) & 0xFF ) ; allocationBlock [ AB_PREVBLOCK_OFFSET ] = ( byte ) ( ( previousBlock [ blockIndex ] >>> 24 ) & 0xFF ) ; allocationBlock [ AB_PREVBLOCK_OFFSET + 1 ] = ( byte ) ( ( previousBlock [ blockIndex ] >>> 16 ) & 0xFF ) ; allocationBlock [ AB_PREVBLOCK_OFFSET + 2 ] = ( byte ) ( ( previousBlock [ blockIndex ] >>> 8 ) & 0xFF ) ; allocationBlock [ AB_PREVBLOCK_OFFSET + 3 ] = ( byte ) ( ( previousBlock [ blockIndex ] >>> 0 ) & 0xFF ) ; allocationBlock [ AB_NEXTBLOCK_OFFSET ] = ( byte ) ( ( nextBlock [ blockIndex ] >>> 24 ) & 0xFF ) ; allocationBlock [ AB_NEXTBLOCK_OFFSET + 1 ] = ( byte ) ( ( nextBlock [ blockIndex ] >>> 16 ) & 0xFF ) ; allocationBlock [ AB_NEXTBLOCK_OFFSET + 2 ] = ( byte ) ( ( nextBlock [ blockIndex ] >>> 8 ) & 0xFF ) ; allocationBlock [ AB_NEXTBLOCK_OFFSET + 3 ] = ( byte ) ( ( nextBlock [ blockIndex ] >>> 0 ) & 0xFF ) ; return allocationBlock ; } | Serialize allocation block at index blockIndex |
4,718 | public void run ( ) { Timeout timeout = Timeout . create ( timeoutId , sagaId , name , clock . now ( ) , data ) ; expiredCallback . expired ( timeout ) ; } | Called by timer as timeout expires . |
4,719 | public void pleaseStop ( ) { if ( stopRequired ) return ; stopRequired = true ; try { if ( receiver != null ) receiver . close ( ) ; } catch ( JMSException e ) { ErrorTools . log ( e , log ) ; } } | Ask the thread to stop |
4,720 | public static byte [ ] copy ( byte [ ] array ) { byte [ ] result = new byte [ array . length ] ; System . arraycopy ( array , 0 , result , 0 , array . length ) ; return result ; } | Copy a byte array |
4,721 | protected final void copyCommonFields ( AbstractMessage clone ) { clone . id = this . id ; clone . correlId = this . correlId ; clone . priority = this . priority ; clone . deliveryMode = this . deliveryMode ; clone . destination = this . destination ; clone . expiration = this . expiration ; clone . redelivered = this . redelivered ; clone . replyTo = this . replyTo ; clone . timestamp = this . timestamp ; clone . type = this . type ; @ SuppressWarnings ( "unchecked" ) Map < String , Object > propertyMapClone = this . propertyMap != null ? ( Map < String , Object > ) ( ( HashMap < String , Object > ) this . propertyMap ) . clone ( ) : null ; clone . propertyMap = propertyMapClone ; clone . unserializationLevel = this . unserializationLevel ; if ( this . rawMessage != null ) clone . rawMessage = this . rawMessage . copy ( ) ; } | Create an independant copy of this message |
4,722 | public final void setSession ( AbstractSession session ) throws JMSException { if ( session == null ) this . sessionRef = null ; else { if ( sessionRef != null && sessionRef . get ( ) != session ) throw new FFMQException ( "Message session already set" , "CONSISTENCY" ) ; this . sessionRef = new WeakReference < > ( session ) ; } } | Set the message session |
4,723 | protected final AbstractSession getSession ( ) throws JMSException { if ( sessionRef == null ) throw new FFMQException ( "Message has no associated session" , "CONSISTENCY" ) ; AbstractSession session = sessionRef . get ( ) ; if ( session == null ) throw new FFMQException ( "Message session is no longer valid" , "CONSISTENCY" ) ; return session ; } | Get the parent session |
4,724 | protected final void serializeTo ( RawDataBuffer out ) { byte lvl1Flags = ( byte ) ( ( priority & 0x0F ) + ( redelivered ? ( 1 << 4 ) : 0 ) + ( deliveryMode == DeliveryMode . PERSISTENT ? ( 1 << 5 ) : 0 ) + ( expiration != 0 ? ( 1 << 6 ) : 0 ) + ( id != null ? ( 1 << 7 ) : 0 ) ) ; out . writeByte ( lvl1Flags ) ; if ( expiration != 0 ) out . writeLong ( expiration ) ; if ( id != null ) out . writeUTF ( id ) ; DestinationSerializer . serializeTo ( destination , out ) ; byte lvl2Flags = ( byte ) ( ( correlId != null ? ( 1 << 0 ) : 0 ) + ( replyTo != null ? ( 1 << 1 ) : 0 ) + ( timestamp != 0 ? ( 1 << 2 ) : 0 ) + ( type != null ? ( 1 << 3 ) : 0 ) + ( propertyMap != null && ! propertyMap . isEmpty ( ) ? ( 1 << 4 ) : 0 ) ) ; out . writeByte ( lvl2Flags ) ; if ( correlId != null ) out . writeUTF ( correlId ) ; if ( replyTo != null ) DestinationSerializer . serializeTo ( replyTo , out ) ; if ( timestamp != 0 ) out . writeLong ( timestamp ) ; if ( type != null ) out . writeUTF ( type ) ; if ( propertyMap != null && ! propertyMap . isEmpty ( ) ) writeMapTo ( propertyMap , out ) ; serializeBodyTo ( out ) ; } | Write the message content to the given output stream |
4,725 | protected final void initializeFromRaw ( RawDataBuffer rawMessage ) { this . rawMessage = rawMessage ; this . unserializationLevel = MessageSerializationLevel . BASE_HEADERS ; byte lvl1Flags = rawMessage . readByte ( ) ; priority = lvl1Flags & 0x0F ; redelivered = ( lvl1Flags & ( 1 << 4 ) ) != 0 ; deliveryMode = ( lvl1Flags & ( 1 << 5 ) ) != 0 ? DeliveryMode . PERSISTENT : DeliveryMode . NON_PERSISTENT ; if ( ( lvl1Flags & ( 1 << 6 ) ) != 0 ) expiration = rawMessage . readLong ( ) ; if ( ( lvl1Flags & ( 1 << 7 ) ) != 0 ) id = rawMessage . readUTF ( ) ; destination = DestinationSerializer . unserializeFrom ( rawMessage ) ; } | Initialize the message from the given raw data |
4,726 | public static void log ( String context , JMSException e , Log log ) { StringBuilder message = new StringBuilder ( ) ; if ( context != null ) { message . append ( "[" ) ; message . append ( context ) ; message . append ( "] " ) ; } if ( e . getErrorCode ( ) != null ) { message . append ( "error={" ) ; message . append ( e . getErrorCode ( ) ) ; message . append ( "} " ) ; } message . append ( e . getMessage ( ) ) ; log . error ( message . toString ( ) ) ; if ( e . getLinkedException ( ) != null ) log . error ( "Linked exception was :" , e . getLinkedException ( ) ) ; } | Log a JMS exception with an error level |
4,727 | public NextSagaToHandle firstExecute ( final Class < ? extends Saga > first ) { orderedTypes . add ( 0 , first ) ; return new NextSagaToHandle ( orderedTypes , builder ) ; } | Define the first saga type to execute in case a message matches multiple ones . |
4,728 | public Module build ( ) { SagaLibModule module = new SagaLibModule ( ) ; module . setStateStorage ( stateStorage ) ; module . setTimeoutManager ( timeoutMgr ) ; module . setScanner ( scanner ) ; module . setProviderFactory ( providerFactory ) ; module . setExecutionOrder ( preferredOrder ) ; module . setExecutionContext ( executionContext ) ; module . setModuleTypes ( moduleTypes ) ; module . setExecutor ( executor ) ; module . setInterceptorTypes ( interceptorTypes ) ; module . setStrategyFinder ( strategyFinder ) ; module . setInvoker ( invoker ) ; module . setCoordinatorFactory ( coordinatorFactory ) ; return module ; } | Creates the module containing all saga lib bindings . |
4,729 | private Iterable < Class < ? > > allMessageTypes ( final Class < ? > concreteMsgClass ) { ClassTypeExtractor extractor = new ClassTypeExtractor ( concreteMsgClass ) ; return extractor . allClassesAndInterfaces ( ) ; } | Creates a list of types the concrete class may have handler matches . Like the implemented interfaces of base classes . |
4,730 | private SagaType containsItem ( final Iterable < SagaType > source , final Class itemToSearch ) { SagaType containedItem = null ; for ( SagaType sagaType : source ) { if ( sagaType . getSagaClass ( ) . equals ( itemToSearch ) ) { containedItem = sagaType ; break ; } } return containedItem ; } | Checks whether the source list contains a saga type matching the input class . |
4,731 | public void unregister ( ActiveObject object ) { synchronized ( watchList ) { for ( int i = 0 ; i < watchList . size ( ) ; i ++ ) { WeakReference < ActiveObject > weakRef = watchList . get ( i ) ; ActiveObject obj = weakRef . get ( ) ; if ( obj == null ) { watchList . remove ( i -- ) ; continue ; } if ( obj == object ) { watchList . remove ( i ) ; break ; } } } } | Unregister a monitored active object |
4,732 | public static synchronized SecurityConnector getConnector ( FFMQEngineSetup setup ) throws JMSException { if ( connector == null ) { String connectorType = setup . getSecurityConnectorType ( ) ; try { Class < ? > connectorClass = Class . forName ( connectorType ) ; connector = ( SecurityConnector ) connectorClass . getConstructor ( new Class [ ] { Settings . class } ) . newInstance ( new Object [ ] { setup . getSettings ( ) } ) ; } catch ( ClassNotFoundException e ) { throw new FFMQException ( "Security connector class not found : " + connectorType , "SECURITY_ERROR" , e ) ; } catch ( ClassCastException e ) { throw new FFMQException ( "Invalid security connector class : " + connectorType , "SECURITY_ERROR" , e ) ; } catch ( InstantiationException e ) { throw new FFMQException ( "Cannot create security connector" , "SECURITY_ERROR" , e . getCause ( ) ) ; } catch ( InvocationTargetException e ) { throw new FFMQException ( "Cannot create security connector" , "SECURITY_ERROR" , e . getTargetException ( ) ) ; } catch ( Exception e ) { throw new FFMQException ( "Cannot create security connector" , "SECURITY_ERROR" , e ) ; } } return connector ; } | Get the security connector instance |
4,733 | public static Number sum ( Number n1 , Number n2 ) { Class < ? > type = getComputationType ( n1 , n2 ) ; Number val1 = convertTo ( n1 , type ) ; Number val2 = convertTo ( n2 , type ) ; if ( type == Long . class ) return Long . valueOf ( val1 . longValue ( ) + val2 . longValue ( ) ) ; return new Double ( val1 . doubleValue ( ) + val2 . doubleValue ( ) ) ; } | Sum two numbers |
4,734 | public static Number minus ( Number n ) { Number value = normalize ( n ) ; Class < ? > type = value . getClass ( ) ; if ( type == Long . class ) return Long . valueOf ( - n . longValue ( ) ) ; return new Double ( - n . doubleValue ( ) ) ; } | Negate a number |
4,735 | public static Boolean greaterThan ( Number n1 , Number n2 ) { Class < ? > type = getComputationType ( n1 , n2 ) ; Number val1 = convertTo ( n1 , type ) ; Number val2 = convertTo ( n2 , type ) ; if ( type == Long . class ) return val1 . longValue ( ) > val2 . longValue ( ) ? Boolean . TRUE : Boolean . FALSE ; return val1 . doubleValue ( ) > val2 . doubleValue ( ) ? Boolean . TRUE : Boolean . FALSE ; } | Compare two numbers |
4,736 | public boolean matches ( Message message ) throws JMSException { Boolean result = selectorTree != null ? selectorTree . evaluateBoolean ( message ) : null ; return result != null && result . booleanValue ( ) ; } | Test the selector against a given message |
4,737 | public final void checkPermission ( Destination destination , String action ) throws JMSException { if ( securityContext == null ) return ; DestinationRef destinationRef = DestinationTools . asRef ( destination ) ; securityContext . checkPermission ( destinationRef . getResourceName ( ) , action ) ; } | Check if the connection has the required credentials to use the given destination |
4,738 | public final void checkPermission ( String resource , String action ) throws JMSException { if ( securityContext == null ) return ; securityContext . checkPermission ( resource , action ) ; } | Check if the connection has the required credentials to use the given resource |
4,739 | protected final Object negate ( Object value ) { if ( value == null ) return null ; return ( ( Boolean ) value ) . booleanValue ( ) ? Boolean . FALSE : Boolean . TRUE ; } | Negate a boolean value |
4,740 | public final Boolean evaluateBoolean ( Message message ) throws JMSException { Object value = evaluate ( message ) ; if ( value == null ) return null ; if ( value instanceof Boolean ) return ( Boolean ) value ; throw new FFMQException ( "Expected a boolean but got : " + value . toString ( ) , "INVALID_SELECTOR_EXPRESSION" ) ; } | Evaluate this node as a boolean |
4,741 | public final Number evaluateNumeric ( Message message ) throws JMSException { Object value = evaluate ( message ) ; if ( value == null ) return null ; if ( value instanceof Number ) return ArithmeticUtils . normalize ( ( Number ) value ) ; throw new FFMQException ( "Expected a numeric but got : " + value . toString ( ) , "INVALID_SELECTOR_EXPRESSION" ) ; } | Evaluate this node as a number |
4,742 | public final String evaluateString ( Message message ) throws JMSException { Object value = evaluate ( message ) ; if ( value == null ) return null ; if ( value instanceof String ) return ( String ) value ; throw new FFMQException ( "Expected a string but got : " + value . toString ( ) , "INVALID_SELECTOR_EXPRESSION" ) ; } | Evaluate this node as a string |
4,743 | protected final int getNodeType ( Object value ) { if ( value instanceof String ) return SelectorNodeType . STRING ; if ( value instanceof Boolean ) return SelectorNodeType . BOOLEAN ; return SelectorNodeType . NUMBER ; } | Get the type of a given value |
4,744 | public boolean register ( String clientID , String subscriptionName ) { String key = clientID + "-" + subscriptionName ; synchronized ( subscriptions ) { if ( subscriptions . containsKey ( key ) ) return false ; subscriptions . put ( key , new DurableTopicSubscription ( System . currentTimeMillis ( ) , clientID , subscriptionName ) ) ; return true ; } } | Register a new durable subscription |
4,745 | public boolean unregister ( String clientID , String subscriptionName ) { String key = clientID + "-" + subscriptionName ; return subscriptions . remove ( key ) != null ; } | Unregister a durable subscription |
4,746 | public boolean isRegistered ( String clientID , String subscriptionName ) { String key = clientID + "-" + subscriptionName ; return subscriptions . containsKey ( key ) ; } | Test if a durable subscription exists |
4,747 | public static byte [ ] serialize ( AbstractMessage message , int typicalSize ) { RawDataBuffer rawMsg = message . getRawMessage ( ) ; if ( rawMsg != null ) return rawMsg . toByteArray ( ) ; RawDataBuffer buffer = new RawDataBuffer ( typicalSize ) ; buffer . writeByte ( message . getType ( ) ) ; message . serializeTo ( buffer ) ; return buffer . toByteArray ( ) ; } | Serialize a message |
4,748 | public static AbstractMessage unserialize ( byte [ ] rawData , boolean asInternalCopy ) { RawDataBuffer rawIn = new RawDataBuffer ( rawData ) ; byte type = rawIn . readByte ( ) ; AbstractMessage message = MessageType . createInstance ( type ) ; message . initializeFromRaw ( rawIn ) ; if ( asInternalCopy ) message . setInternalCopy ( true ) ; return message ; } | Unserialize a message |
4,749 | public static void serializeTo ( AbstractMessage message , RawDataBuffer out ) { RawDataBuffer rawMsg = message . getRawMessage ( ) ; if ( rawMsg != null ) { out . writeInt ( rawMsg . size ( ) ) ; rawMsg . writeTo ( out ) ; } else { out . writeInt ( 0 ) ; int startPos = out . size ( ) ; out . writeByte ( message . getType ( ) ) ; message . serializeTo ( out ) ; int endPos = out . size ( ) ; out . writeInt ( endPos - startPos , startPos - 4 ) ; } } | Serialize a message to the given output stream |
4,750 | public static AbstractMessage unserializeFrom ( RawDataBuffer rawIn , boolean asInternalCopy ) { int size = rawIn . readInt ( ) ; RawDataBuffer rawMessage = new RawDataBuffer ( rawIn . readBytes ( size ) ) ; byte type = rawMessage . readByte ( ) ; AbstractMessage message = MessageType . createInstance ( type ) ; message . initializeFromRaw ( rawMessage ) ; if ( asInternalCopy ) message . setInternalCopy ( true ) ; return message ; } | Unserialize a message from the given input stream |
4,751 | public static String rightPad ( String value , int size , char padChar ) { if ( value . length ( ) >= size ) return value ; StringBuilder result = new StringBuilder ( size ) ; result . append ( value ) ; for ( int n = 0 ; n < size - value . length ( ) ; n ++ ) result . append ( padChar ) ; return result . toString ( ) ; } | Right pad the given string |
4,752 | public static String formatSize ( long size ) { if ( size == 0 ) return "0" ; StringBuilder sb = new StringBuilder ( ) ; if ( size < 0 ) { size = - size ; sb . append ( "-" ) ; } long gigs = size / ( 1024 * 1024 * 1024 ) ; if ( gigs > 0 ) { sb . append ( new DecimalFormat ( "######.###" ) . format ( ( double ) size / ( 1024 * 1024 * 1024 ) ) ) ; sb . append ( " GB" ) ; return sb . toString ( ) ; } long megs = size / ( 1024 * 1024 ) ; if ( megs > 0 ) { sb . append ( new DecimalFormat ( "###.#" ) . format ( ( double ) size / ( 1024 * 1024 ) ) ) ; sb . append ( " MB" ) ; return sb . toString ( ) ; } long kbs = size / ( 1024 ) ; if ( kbs > 0 ) { sb . append ( new DecimalFormat ( "###.#" ) . format ( ( double ) size / ( 1024 ) ) ) ; sb . append ( " KB" ) ; return sb . toString ( ) ; } sb . append ( size ) ; sb . append ( " B" ) ; return sb . toString ( ) ; } | Format the given size |
4,753 | public synchronized void close ( ) throws IOException { if ( ! opened ) { return ; } opened = false ; accessor . close ( ) ; appender . close ( ) ; hints . clear ( ) ; inflightWrites . clear ( ) ; if ( managedWriter ) { ( ( ExecutorService ) writer ) . shutdown ( ) ; writer = null ; } if ( managedDisposer ) { disposer . shutdown ( ) ; disposer = null ; } } | Close the journal . |
4,754 | public void sync ( ) throws ClosedJournalException , IOException { try { appender . sync ( ) . get ( ) ; if ( appender . getAsyncException ( ) != null ) { throw new IOException ( appender . getAsyncException ( ) ) ; } } catch ( Exception ex ) { throw new IllegalStateException ( ex . getMessage ( ) , ex ) ; } } | Sync asynchronously written records on disk . |
4,755 | public synchronized void truncate ( ) throws OpenJournalException , IOException { if ( ! opened ) { for ( DataFile file : dataFiles . values ( ) ) { removeDataFile ( file ) ; } } else { throw new OpenJournalException ( "The journal is open! The journal must be closed to be truncated." ) ; } } | Truncate the journal removing all log files . Please note truncate requires the journal to be closed . |
4,756 | public Iterable < Location > redo ( ) throws ClosedJournalException , CompactedDataFileException , IOException { Entry < Integer , DataFile > firstEntry = dataFiles . firstEntry ( ) ; if ( firstEntry == null ) { return new Redo ( null ) ; } return new Redo ( goToFirstLocation ( firstEntry . getValue ( ) , Location . USER_RECORD_TYPE , true ) ) ; } | Return an iterable to replay the journal by going through all records locations . |
4,757 | public Iterable < Location > redo ( Location start ) throws ClosedJournalException , CompactedDataFileException , IOException { return new Redo ( start ) ; } | Return an iterable to replay the journal by going through all records locations starting from the given one . |
4,758 | public Iterable < Location > undo ( Location end ) throws ClosedJournalException , CompactedDataFileException , IOException { return new Undo ( redo ( end ) ) ; } | Return an iterable to replay the journal in reverse starting with the newest location and ending with the specified end location . The iterable does not include future writes - writes that happen after its creation . |
4,759 | public List < File > getFiles ( ) { List < File > result = new LinkedList < File > ( ) ; for ( DataFile dataFile : dataFiles . values ( ) ) { result . add ( dataFile . getFile ( ) ) ; } return result ; } | Get the files part of this journal . |
4,760 | public final void exceptionOccured ( JMSException exception ) { try { synchronized ( exceptionListenerLock ) { if ( exceptionListener != null ) exceptionListener . onException ( exception ) ; } } catch ( Exception e ) { log . error ( "Exception listener failed" , e ) ; } } | Triggered when a JMSException is internally catched |
4,761 | private void dropTemporaryQueues ( ) { synchronized ( temporaryQueues ) { Iterator < String > remainingQueues = temporaryQueues . iterator ( ) ; while ( remainingQueues . hasNext ( ) ) { String queueName = remainingQueues . next ( ) ; try { deleteTemporaryQueue ( queueName ) ; } catch ( JMSException e ) { ErrorTools . log ( e , log ) ; } } } } | Drop all registered temporary queues |
4,762 | private void closeRemainingSessions ( ) { if ( sessions == null ) return ; List < AbstractSession > sessionsToClose = new ArrayList < > ( sessions . size ( ) ) ; synchronized ( sessions ) { sessionsToClose . addAll ( sessions . values ( ) ) ; } for ( int n = 0 ; n < sessionsToClose . size ( ) ; n ++ ) { Session session = sessionsToClose . get ( n ) ; log . debug ( "Auto-closing unclosed session : " + session ) ; try { session . close ( ) ; } catch ( JMSException e ) { ErrorTools . log ( e , log ) ; } } } | Close remaining sessions |
4,763 | protected final void waitForDeliverySync ( ) { List < AbstractSession > sessionsSnapshot = new ArrayList < > ( sessions . size ( ) ) ; synchronized ( sessions ) { sessionsSnapshot . addAll ( sessions . values ( ) ) ; } for ( int n = 0 ; n < sessionsSnapshot . size ( ) ; n ++ ) { AbstractSession session = sessionsSnapshot . get ( n ) ; session . waitForDeliverySync ( ) ; } } | Wait for sessions to finish the current deliveridispatching |
4,764 | protected final void registerSession ( AbstractSession sessionToAdd ) { if ( sessions . put ( sessionToAdd . getId ( ) , sessionToAdd ) != null ) throw new IllegalArgumentException ( "Session " + sessionToAdd . getId ( ) + " already exists" ) ; } | Register a session |
4,765 | public final void unregisterSession ( AbstractSession sessionToRemove ) { if ( sessions . remove ( sessionToRemove . getId ( ) ) == null ) log . warn ( "Unknown session : " + sessionToRemove ) ; } | Unregister a session |
4,766 | public int getConsumersCount ( ) { synchronized ( sessions ) { if ( sessions . isEmpty ( ) ) return 0 ; int total = 0 ; Iterator < AbstractSession > sessionsIterator = sessions . values ( ) . iterator ( ) ; while ( sessionsIterator . hasNext ( ) ) { AbstractSession session = sessionsIterator . next ( ) ; total += session . getConsumersCount ( ) ; } return total ; } } | Get the number of active producers for this connection |
4,767 | private void signalBatch ( ) { writer . execute ( new Runnable ( ) { public void run ( ) { while ( writing . compareAndSet ( false , true ) == false ) { try { Thread . sleep ( SPIN_BACKOFF ) ; } catch ( Exception ex ) { } } WriteBatch wb = batchQueue . poll ( ) ; try { while ( wb != null ) { if ( ! wb . isEmpty ( ) ) { boolean newOrRotated = lastAppendDataFile != wb . getDataFile ( ) ; if ( newOrRotated ) { if ( lastAppendRaf != null ) { lastAppendRaf . close ( ) ; } lastAppendDataFile = wb . getDataFile ( ) ; lastAppendRaf = lastAppendDataFile . openRandomAccessFile ( ) ; } Location batchLocation = wb . perform ( lastAppendRaf , journal . isChecksum ( ) , journal . isPhysicalSync ( ) , journal . getReplicationTarget ( ) ) ; journal . getHints ( ) . put ( batchLocation , batchLocation . getThisFilePosition ( ) ) ; journal . addToTotalLength ( wb . getSize ( ) ) ; for ( WriteCommand current : wb . getWrites ( ) ) { try { current . getLocation ( ) . getWriteCallback ( ) . onSync ( current . getLocation ( ) ) ; } catch ( Throwable ex ) { warn ( ex , ex . getMessage ( ) ) ; } journal . getInflightWrites ( ) . remove ( current . getLocation ( ) ) ; } wb . getLatch ( ) . countDown ( ) ; } wb = batchQueue . poll ( ) ; } } catch ( Exception ex ) { batchQueue . offer ( wb ) ; for ( WriteBatch currentBatch : batchQueue ) { for ( WriteCommand currentWrite : currentBatch . getWrites ( ) ) { try { currentWrite . getLocation ( ) . getWriteCallback ( ) . onError ( currentWrite . getLocation ( ) , ex ) ; } catch ( Throwable innerEx ) { warn ( innerEx , innerEx . getMessage ( ) ) ; } } currentBatch . getLatch ( ) . countDown ( ) ; } asyncException . compareAndSet ( null , ex ) ; } finally { writing . set ( false ) ; } } } ) ; } | Signal writer thread to process batches . |
4,768 | public static void create ( String baseName , File dataFolder , int blockCount , int blockSize , boolean forceSync ) throws DataStoreException { if ( blockCount <= 0 ) throw new DataStoreException ( "Block count should be > 0" ) ; if ( blockSize <= 0 ) throw new DataStoreException ( "Block size should be > 0" ) ; File atFile = new File ( dataFolder , baseName + AbstractBlockBasedDataStore . ALLOCATION_TABLE_SUFFIX ) ; File dataFile = new File ( dataFolder , baseName + AbstractBlockBasedDataStore . DATA_FILE_SUFFIX ) ; if ( atFile . exists ( ) ) throw new DataStoreException ( "Cannot create store filesystem : " + atFile . getAbsolutePath ( ) + " already exists" ) ; if ( dataFile . exists ( ) ) throw new DataStoreException ( "Cannot create store filesystem : " + dataFile . getAbsolutePath ( ) + " already exists" ) ; initAllocationTable ( atFile , blockCount , blockSize , forceSync ) ; initDataFile ( dataFile , blockCount , blockSize , forceSync ) ; } | Create the filesystem for a new store |
4,769 | private static void initAllocationTable ( File atFile , int blockCount , int blockSize , boolean forceSync ) throws DataStoreException { log . debug ( "Creating allocation table (size=" + blockCount + ") ..." ) ; try { FileOutputStream outFile = new FileOutputStream ( atFile ) ; DataOutputStream out = new DataOutputStream ( new BufferedOutputStream ( outFile ) ) ; out . writeInt ( blockCount ) ; out . writeInt ( blockSize ) ; out . writeInt ( - 1 ) ; for ( int n = 0 ; n < blockCount ; n ++ ) out . write ( EMPTY_BLOCK ) ; out . flush ( ) ; if ( forceSync ) outFile . getFD ( ) . sync ( ) ; out . close ( ) ; } catch ( IOException e ) { throw new DataStoreException ( "Cannot initialize allocation table " + atFile . getAbsolutePath ( ) , e ) ; } } | one 0 byte and three - 1 ints |
4,770 | public static void delete ( String baseName , File dataFolder , boolean force ) throws DataStoreException { File [ ] journalFiles = findJournalFiles ( baseName , dataFolder ) ; if ( journalFiles . length > 0 ) { if ( force ) { for ( int i = 0 ; i < journalFiles . length ; i ++ ) { if ( ! journalFiles [ i ] . delete ( ) ) throw new DataStoreException ( "Cannot delete file : " + journalFiles [ i ] . getAbsolutePath ( ) ) ; } } else throw new DataStoreException ( "Journal file exist : " + journalFiles [ 0 ] . getAbsolutePath ( ) ) ; } File atFile = new File ( dataFolder , baseName + AbstractBlockBasedDataStore . ALLOCATION_TABLE_SUFFIX ) ; if ( atFile . exists ( ) ) if ( ! atFile . delete ( ) ) throw new DataStoreException ( "Cannot delete file : " + atFile . getAbsolutePath ( ) ) ; File dataFile = new File ( dataFolder , baseName + AbstractBlockBasedDataStore . DATA_FILE_SUFFIX ) ; if ( dataFile . exists ( ) ) if ( ! dataFile . delete ( ) ) throw new DataStoreException ( "Cannot delete file : " + dataFile . getAbsolutePath ( ) ) ; } | Delete the filesystem of a store |
4,771 | public static File [ ] findJournalFiles ( String baseName , File dataFolder ) { final String journalBase = baseName + JournalFile . SUFFIX ; File [ ] journalFiles = dataFolder . listFiles ( new FileFilter ( ) { public boolean accept ( File pathname ) { if ( ! pathname . isFile ( ) ) return false ; return pathname . getName ( ) . startsWith ( journalBase ) && ! pathname . getName ( ) . endsWith ( JournalFile . RECYCLED_SUFFIX ) ; } } ) ; Arrays . sort ( journalFiles , new Comparator < File > ( ) { public int compare ( File f1 , File f2 ) { return f1 . getName ( ) . compareTo ( f2 . getName ( ) ) ; } } ) ; return journalFiles ; } | Find existing journal files for a given base name |
4,772 | public static File [ ] findRecycledJournalFiles ( String baseName , File dataFolder ) { final String journalBase = baseName + JournalFile . SUFFIX ; File [ ] recycledFiles = dataFolder . listFiles ( new FileFilter ( ) { public boolean accept ( File pathname ) { if ( ! pathname . isFile ( ) ) return false ; return pathname . getName ( ) . startsWith ( journalBase ) && pathname . getName ( ) . endsWith ( JournalFile . RECYCLED_SUFFIX ) ; } } ) ; return recycledFiles ; } | Find recycled journal files for a given base name |
4,773 | public synchronized void execute ( AsyncTask task ) throws JMSException { AsyncTaskProcessorThread thread = threadPool . borrow ( ) ; if ( thread != null ) { thread . setTask ( task ) ; thread . execute ( ) ; } else { if ( task . isMergeable ( ) ) { if ( ! taskSet . add ( task ) ) return ; } taskQueue . add ( task ) ; } } | Asynchronously execute the given task |
4,774 | protected final URI getProviderURI ( ) throws JMSException { String providerURL = getProviderURL ( ) ; URI parsedURL ; try { parsedURL = new URI ( providerURL ) ; } catch ( URISyntaxException e ) { throw new FFMQException ( "Malformed provider URL : " + providerURL , "INVALID_PROVIDER_URL" ) ; } if ( ! parsedURL . isAbsolute ( ) ) throw new FFMQException ( "Invalid provider URL : " + providerURL , "INVALID_PROVIDER_URL" ) ; return parsedURL ; } | Lookup the provider URI |
4,775 | public int recover ( ) throws JournalException { int newBlockCount = - 1 ; log . warn ( "[" + baseName + "] Recovery required for data store : found " + journalFiles . length + " journal file(s)" ) ; for ( int i = 0 ; i < journalFiles . length ; i ++ ) newBlockCount = recoverFromJournalFile ( journalFiles [ i ] ) ; return newBlockCount ; } | Start the recovery process |
4,776 | public static void serializeTo ( AbstractPacket packet , RawDataBuffer out ) { out . writeByte ( packet . getType ( ) ) ; packet . serializeTo ( out ) ; } | Serialize a packet to the given output stream |
4,777 | public static AbstractPacket unserializeFrom ( RawDataBuffer in ) { byte type = in . readByte ( ) ; AbstractPacket packet = PacketType . createInstance ( type ) ; packet . unserializeFrom ( in ) ; return packet ; } | Unserialize a packet from the given input stream |
4,778 | public static void closeQuietly ( final AutoCloseable closeable ) { try { if ( closeable != null ) { closeable . close ( ) ; } } catch ( Exception e ) { LOG . warn ( "Error closing instance {}." , closeable , e ) ; } } | Calls close on the provided instance . If an exception occurs it is logged instead of propagating it . |
4,779 | public void ensureCapacity ( int requiredBits ) { int requiredWords = wordIndex ( requiredBits - 1 ) + 1 ; if ( words . length < requiredWords ) { long [ ] newWords = new long [ requiredWords ] ; System . arraycopy ( words , 0 , newWords , 0 , words . length ) ; words = newWords ; } } | Ensures that the BitSet can hold enough bits . |
4,780 | public boolean flip ( int bitIndex ) { int wordIndex = wordIndex ( bitIndex ) ; words [ wordIndex ] ^= ( 1L << bitIndex ) ; return ( ( words [ wordIndex ] & ( 1L << bitIndex ) ) != 0 ) ; } | Sets the bit at the specified index to the complement of its current value . |
4,781 | public SelectorNode parse ( ) throws InvalidSelectorException { if ( isEndOfExpression ( ) ) return null ; SelectorNode expr = parseExpression ( ) ; if ( ! isEndOfExpression ( ) ) throw new InvalidSelectorException ( "Unexpected token : " + currentToken ) ; if ( ! ( expr instanceof ConditionalExpression ) ) throw new InvalidSelectorException ( "Selector expression is not a boolean expression" ) ; return expr ; } | Parse the given message selector expression into a selector node tree |
4,782 | public void unlockAndDeliver ( MessageLock lockRef ) throws JMSException { MessageStore targetStore ; if ( lockRef . getDeliveryMode ( ) == DeliveryMode . NON_PERSISTENT ) targetStore = volatileStore ; else targetStore = persistentStore ; int handle = lockRef . getHandle ( ) ; AbstractMessage message = lockRef . getMessage ( ) ; synchronized ( storeLock ) { targetStore . unlock ( handle ) ; } sentToQueueCount . incrementAndGet ( ) ; sendAvailabilityNotification ( message ) ; } | Unlock a message . Listeners are automatically notified of the new message availability . |
4,783 | public void removeLocked ( MessageLock lockRef ) throws JMSException { checkTransactionLock ( ) ; MessageStore targetStore ; if ( lockRef . getDeliveryMode ( ) == DeliveryMode . NON_PERSISTENT ) targetStore = volatileStore ; else { targetStore = persistentStore ; if ( requiresTransactionalUpdate ( ) ) pendingChanges = true ; } synchronized ( storeLock ) { targetStore . delete ( lockRef . getHandle ( ) ) ; } } | Remove a locked message from this queue . The message is deleted from the underlying store . |
4,784 | public AbstractMessage browse ( LocalQueueBrowserCursor cursor , MessageSelector selector ) throws JMSException { cursor . reset ( ) ; if ( volatileStore != null ) { AbstractMessage msg = browseStore ( volatileStore , cursor , selector ) ; if ( msg != null ) { cursor . move ( ) ; return msg ; } } if ( persistentStore != null ) { AbstractMessage msg = browseStore ( persistentStore , cursor , selector ) ; if ( msg != null ) { cursor . move ( ) ; return msg ; } } cursor . setEndOfQueueReached ( ) ; return null ; } | Browse a message in this queue |
4,785 | public void purge ( MessageSelector selector ) throws JMSException { if ( volatileStore != null ) purgeStore ( volatileStore , selector ) ; if ( persistentStore != null ) { openTransaction ( ) ; try { purgeStore ( persistentStore , selector ) ; commitChanges ( ) ; } finally { closeTransaction ( ) ; } } } | Purge some messages from the buffer |
4,786 | private void notifyConsumer ( AbstractMessage message ) { consumersLock . readLock ( ) . lock ( ) ; try { switch ( localConsumers . size ( ) ) { case 0 : return ; case 1 : notifySingleConsumer ( localConsumers . get ( 0 ) , message ) ; break ; default : notifyNextConsumer ( localConsumers , message ) ; break ; } } finally { consumersLock . readLock ( ) . unlock ( ) ; } } | Notify a consumer that a message is probably available for it to retrieve |
4,787 | private void timeoutHasExpired ( final Timeout timeout , final TimeoutExpirationContext context ) { try { addMessage ( timeout , context . getOriginalHeaders ( ) ) ; } catch ( Exception ex ) { LOG . error ( "Error handling timeout {}" , timeout , ex ) ; } } | Called whenever the timeout manager reports an expired timeout . |
4,788 | private void populateSagaHandlers ( ) { synchronized ( sync ) { if ( scanResult == null ) { scanResult = new HashMap < > ( ) ; Collection < Class < ? extends Saga > > sagaTypes = scanner . scanForSagas ( ) ; for ( Class < ? extends Saga > sagaType : sagaTypes ) { SagaHandlersMap messageHandlers = determineMessageHandlers ( sagaType ) ; scanResult . put ( sagaType , messageHandlers ) ; } } } } | Creates entries in the scan result map containing the messages handlers of the sagas provided by the injected scanner . |
4,789 | private SagaHandlersMap determineMessageHandlers ( final Class < ? extends Saga > sagaType ) { SagaHandlersMap handlerMap = new SagaHandlersMap ( sagaType ) ; Method [ ] methods = sagaType . getMethods ( ) ; for ( Method method : methods ) { if ( isHandlerMethod ( method ) ) { Class < ? > handlerType = method . getParameterTypes ( ) [ 0 ] ; boolean isSagaStart = hasStartSagaAnnotation ( method ) ; handlerMap . add ( MessageHandler . reflectionInvokedHandler ( handlerType , method , isSagaStart ) ) ; } } return handlerMap ; } | Checks all methods for saga annotations . |
4,790 | private boolean isHandlerMethod ( final Method method ) { boolean isHandler = false ; if ( hasStartSagaAnnotation ( method ) || hasHandlerAnnotation ( method ) ) { if ( method . getReturnType ( ) . equals ( Void . TYPE ) ) { Class < ? > [ ] parameterTypes = method . getParameterTypes ( ) ; if ( parameterTypes . length == 1 ) { isHandler = true ; } else { LOG . warn ( "Method {}.{} marked for saga does not have the expected single parameter." , method . getDeclaringClass ( ) , method . getName ( ) ) ; } } else { LOG . warn ( "Method {}.{} marked for saga event handling but does return a value." , method . getDeclaringClass ( ) , method . getName ( ) ) ; } } return isHandler ; } | Checks whether method has expected annotation arguments as well as signature . |
4,791 | public void addLast ( AbstractJournalOperation op ) { if ( tail == null ) { head = tail = op ; } else { tail . setNext ( op ) ; tail = op ; } op . setNext ( null ) ; size ++ ; } | Append an operation at the end of the queue |
4,792 | public AbstractJournalOperation removeFirst ( ) { AbstractJournalOperation op = head ; if ( op == null ) throw new NoSuchElementException ( ) ; head = op . next ( ) ; if ( head == null ) tail = null ; op . setNext ( null ) ; size -- ; return op ; } | Remove the first available journal operation in queue |
4,793 | public void migrateTo ( JournalQueue otherQueue ) { if ( head == null ) return ; if ( otherQueue . head == null ) { otherQueue . head = head ; otherQueue . tail = tail ; otherQueue . size = size ; } else { otherQueue . tail . setNext ( head ) ; otherQueue . tail = tail ; otherQueue . size += size ; } head = tail = null ; size = 0 ; } | Migrate all operations to the given target queue |
4,794 | public Saga createNew ( final Class < ? extends Saga > sagaType ) throws ExecutionException { Saga newInstance = createNewInstance ( sagaType ) ; if ( newInstance instanceof NeedTimeouts ) { ( ( NeedTimeouts ) newInstance ) . setTimeoutManager ( timeoutManager ) ; } return newInstance ; } | Creates a new saga instances with the requested type . |
4,795 | public static byte [ ] toByteArray ( Serializable object ) { try { ByteArrayOutputStream buf = new ByteArrayOutputStream ( 1024 ) ; ObjectOutputStream objOut = new ObjectOutputStream ( buf ) ; objOut . writeObject ( object ) ; objOut . close ( ) ; return buf . toByteArray ( ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Cannot serialize object : " + e . toString ( ) ) ; } } | Object to byte array |
4,796 | public static Serializable fromByteArray ( byte [ ] data ) { try { ByteArrayInputStream buf = new ByteArrayInputStream ( data ) ; ObjectInputStream objIn = new ObjectInputStream ( buf ) ; Serializable response = ( Serializable ) objIn . readObject ( ) ; objIn . close ( ) ; return response ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Cannot deserialize object : " + e . toString ( ) ) ; } } | Byte array to object |
4,797 | protected ClientProcessor createProcessor ( String clientId , Socket clientSocket ) throws PacketTransportException { PacketTransport transport = new TcpPacketTransport ( clientId , clientSocket , settings ) ; ClientProcessor clientProcessor = new ClientProcessor ( clientId , this , localEngine , transport ) ; return clientProcessor ; } | Create a new processor |
4,798 | private void updateStateStorage ( final SagaInstanceInfo description , final CurrentExecutionContext context ) { Saga saga = description . getSaga ( ) ; String sagaId = saga . state ( ) . getSagaId ( ) ; if ( saga . isFinished ( ) && ! description . isStarting ( ) ) { cleanupSagaSate ( sagaId ) ; } else if ( saga . isFinished ( ) && description . isStarting ( ) ) { if ( context . hasBeenStored ( sagaId ) ) { cleanupSagaSate ( sagaId ) ; } } if ( ! saga . isFinished ( ) ) { context . recordSagaStateStored ( sagaId ) ; env . storage ( ) . save ( saga . state ( ) ) ; } } | Updates the state storage depending on whether the saga is completed or keeps on running . |
4,799 | public TopicDefinition createTopicDefinition ( String topicName , boolean temporary ) { TopicDefinition def = new TopicDefinition ( ) ; def . setName ( topicName ) ; def . setTemporary ( temporary ) ; copyAttributesTo ( def ) ; def . setSubscriberFailurePolicy ( subscriberFailurePolicy ) ; def . setSubscriberOverflowPolicy ( subscriberOverflowPolicy ) ; def . setPartitionsKeysToIndex ( partitionsKeysToIndex ) ; return def ; } | Create a topic definition from this template |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.