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_CONN...
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 :: getKe...
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 ( ) ) ...
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...
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 ( ) ) ; } ...
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 { callb...
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 ...
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...
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...
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 ...
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_ALLOCSI...
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...
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 < > ( ses...
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" , "CONSI...
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 ( e...
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 = ( lvl1...
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 ...
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 . setExecutionContex...
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 )...
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 . get...
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 . doubleVa...
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 val...
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_EXPRESSI...
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 ( )...
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 , subsc...
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 ( ...
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 . set...
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 . getT...
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 ) ; messag...
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 / (...
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 ...
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 . US...
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 . ...
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...
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 = sessionsSnapsh...
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 += sessi...
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 ( ) ) {...
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 ...
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 DataOutputStr...
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 ( )...
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 . get...
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 pathn...
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 . isAb...
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 ] ) ; ret...
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 I...
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 . getMes...
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 = ...
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 !...
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 ; } } fina...
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 = determineMessageHandle...
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 . getPara...
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 ...
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...
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 Ill...
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 ) { th...
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 c...
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 . isF...
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 . setSubscriberOverflowPo...
Create a topic definition from this template