idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
136,500
public static boolean isReservedVariable ( String variableName ) { return ReservedVariables . NOW . equalsIgnoreCase ( variableName ) || ReservedVariables . WORKFLOW_INSTANCE_ID . equalsIgnoreCase ( variableName ) ; }
Checks if the given variable name is a reserved keyword and SHOULD NOT be used as a key for an Environment attribute .
136,501
private Tree < Row > findIf ( Tree < Row > pointer ) { while ( ! Type . IF . equals ( pointer . getContent ( ) . getType ( ) ) ) { pointer = pointer . getPrevious ( ) ; } return pointer ; }
Finds the associate IF for an ELSE_IF ELSE or END_IF pointer .
136,502
private Tree < Row > findEndIf ( Tree < Row > pointer ) { while ( ! Type . END_IF . equals ( pointer . getContent ( ) . getType ( ) ) ) { pointer = pointer . getNext ( ) ; } return pointer ; }
Finds the associate END_IF for an IF ELSE_IF or ELSE pointer
136,503
private Tree < Row > findNext ( Tree < Row > pointer ) { if ( pointer . hasNext ( ) ) { if ( Type . END . equals ( pointer . getNext ( ) . getContent ( ) . getType ( ) ) ) { return null ; } else { return pointer . getNext ( ) ; } } Tree < Row > parent = pointer . getParent ( ) ; Type parentType = parent . getContent ( ...
Finds the following node which to create a transition to . Supports tree - nodes that are not the last in their block and those which are last .
136,504
public static Method findMatchingMethod ( Class < ? > classToInspect , Class < ? > returnType , Object ... params ) { Method [ ] methods = classToInspect . getMethods ( ) ; Method checkedMethod = null ; for ( Method method : methods ) { Type [ ] parameterTypes = method . getParameterTypes ( ) ; boolean matchReturnType ...
Finds a method matching the given parameters and return type .
136,505
@ SuppressWarnings ( "unchecked" ) public static < T > Constructor < T > findMatchingConstructor ( Class < T > classToInspect , Object ... params ) { Constructor < T > checkedConstructors = null ; for ( Constructor < ? > constructor : classToInspect . getDeclaredConstructors ( ) ) { Type [ ] parameterTypes = constructo...
Finds a constructor matching the given parameters .
136,506
protected < A extends AggregateRoot < ? > > A createFromFactory ( Class < A > aggregateClass , Object ... parameters ) { checkNotNull ( aggregateClass ) ; checkNotNull ( parameters ) ; Factory < A > factory = domainRegistry . getFactory ( aggregateClass ) ; Method factoryMethod ; boolean useDefaultFactory = false ; try...
Implements the logic to create an aggregate .
136,507
static void serialize ( final Document doc , final OutputStream os , final String encoding ) throws TransformerFactoryConfigurationError , TransformerException , IOException { if ( doc == null ) throw new IllegalArgumentException ( "No document provided." ) ; if ( os == null ) throw new IllegalArgumentException ( "No o...
Serializes a DOM . The OutputStream handed over to this method is not closed inside this method .
136,508
public byte [ ] toByteArray ( ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( 16 ) ; outputStream . write ( commandByte ) ; outputStream . write ( sysexCommandByte ) ; if ( serialize ( outputStream ) ) { outputStream . write ( CommandBytes . END_SYSEX . getCommandByte ( ) ) ; return outputStream . ...
Combine the SysexCommandByte and the serialized sysex message packet together to form a Firmata supported sysex byte packet to be sent over the SerialPort .
136,509
protected boolean isValidFragment ( String fragmentName ) { Boolean knownFrag = false ; for ( Class < ? > cls : INNER_CLASSES ) { if ( cls . getName ( ) . equals ( fragmentName ) ) { knownFrag = true ; break ; } } return knownFrag ; }
Google found a security vulnerability and imposed this hack . Have to check this fragment was actually conceived by this activity .
136,510
public byte [ ] toByteArray ( ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( 32 ) ; outputStream . write ( commandByte ) ; if ( serialize ( outputStream ) ) { return outputStream . toByteArray ( ) ; } return null ; }
Combine the CommandByte and the serialized message packet together to form a Firmata supported byte packet to be sent over the SerialPort .
136,511
protected void fireEvent ( SerialPortEventTypes eventType ) { executor . submit ( new Runnable ( ) { public void run ( ) { for ( SerialPortEventListener listener : eventListeners ) { listener . serialEvent ( new SerialPortEvent ( eventType ) ) ; } } } ) ; }
Tell the client if there is data available etc .
136,512
public ArrayList < PinCapability > getPinCapabilities ( Integer pin ) { if ( pinCapabilities . size ( ) >= pin ) { return pinCapabilities . get ( pin ) ; } return null ; }
Get Pin Capabilities Get a list of modes that a given pin supports .
136,513
public void addMessageListener ( Integer channel , MessageListener < ? extends Message > messageListener ) { addListener ( channel , messageListener . getMessageType ( ) , messageListener ) ; }
Add a messageListener to the Firmta object which will fire whenever a matching message is received over the SerialPort that corresponds to the given channel .
136,514
public void addMessageListener ( DigitalChannel channel , MessageListener < ? extends Message > messageListener ) { addListener ( channel . getIdentifier ( ) , messageListener . getMessageType ( ) , messageListener ) ; }
Add a messageListener to the Firmata object which will fire whenever a matching message is received over the SerialPort that corresponds to the given DigitalChannel .
136,515
public void addMessageListener ( Class < ? extends Message > messageClass , MessageListener < Message > messageListener ) { addMessageListener ( messageListener . getChannelIdentifier ( ) , messageClass , messageListener ) ; }
Add a generic message listener to listen for a specific type of message . Useful if you want to combine several or more message handlers into one bucket .
136,516
public void removeMessageListener ( Class < ? extends Message > messageClass , MessageListener < Message > messageListener ) { removeMessageListener ( messageListener . getChannelIdentifier ( ) , messageClass , messageListener ) ; }
Remove a generic message listener from listening to a specific type of message .
136,517
public synchronized Boolean sendMessage ( TransmittableMessage message ) { if ( ! start ( ) ) { log . error ( "Firmata library is not connected / started! Cannot send message {}" , message . getClass ( ) . getSimpleName ( ) ) ; return false ; } try { log . debug ( "Transmitting message {}. Bytes: {}" , message . getCla...
Send a Message over the serial port to a Firmata supported device .
136,518
public synchronized Boolean sendRaw ( byte ... rawBytes ) { if ( ! start ( ) ) { log . error ( "Firmata library is not connected / started! Cannot send bytes {}" , FirmataHelper . bytesToHexString ( rawBytes ) ) ; return false ; } try { serialPort . getOutputStream ( ) . write ( rawBytes ) ; return true ; } catch ( IOE...
Send a series of raw bytes over the serial port to a Firmata supported device .
136,519
public synchronized Boolean start ( ) { if ( started ) { return true ; } createSerialPort ( ) ; serialPort . addEventListener ( this ) ; if ( ! serialPort . connect ( ) ) { log . error ( "Failed to start Firmata Library. Cannot connect to Serial Port." ) ; log . error ( "Configuration is {}" , configuration ) ; stop ( ...
Starts the firmata library . If the library is already started this will just return true . Starts the SerialPort and handlers and ensures the attached device is able to communicate with our library . This will return an UnsupportedDevice exception if the attached device does not meet the library requirements .
136,520
public synchronized Boolean stop ( ) { if ( serialPort != null ) { serialPort . removeEventListener ( this ) ; } if ( ! removeSerialPort ( ) ) { log . error ( "Failed to stop Firmata Library. Cannot close Serial Port." ) ; log . error ( "Configuration is {}" , configuration ) ; return false ; } started = false ; return...
Stops the Firmata library . If the library is already stopped this will still attempt to stop anything that may still be lingering . Take note that many calls could eventually result in noticeable cpu usage .
136,521
private void createSerialPort ( ) { Constructor < ? extends SerialPort > constructor ; try { constructor = configuration . getSerialPortAdapterClass ( ) . getDeclaredConstructor ( String . class , Integer . class , SerialPortDataBits . class , SerialPortStopBits . class , SerialPortParity . class ) ; } catch ( NoSuchMe...
Generate the SerialPort object using the SerialPort adapter class provided in the FirmataConfiguration If there is any issue constructing this object toss a RuntimeException as this is a developer error in implementing the SerialPort adapter for this library .
136,522
private Boolean removeSerialPort ( ) { Boolean ret = true ; if ( serialPort != null ) { ret = serialPort . disconnect ( ) ; serialPort = null ; } return ret ; }
Disconnect from the SerialPort object that we are communicating with over the Firmata protocol .
136,523
private void handleDataAvailable ( ) { InputStream inputStream = serialPort . getInputStream ( ) ; try { while ( inputStream . available ( ) > 0 ) { byte inputByte = ( byte ) inputStream . read ( ) ; if ( inputByte == - 1 ) { log . error ( "Reached end of stream trying to read serial port." ) ; stop ( ) ; return ; } Me...
Handles the SerialPort input stream and builds a message object if a detected CommandByte is discovered over the communications stream .
136,524
private void routeMessage ( Message message ) { Class messageClass = message . getClass ( ) ; if ( messageListenerMap . containsKey ( messageClass ) ) { dispatchMessage ( messageListenerMap . get ( messageClass ) , message ) ; } if ( messageListenerMap . containsKey ( Message . class ) ) { dispatchMessage ( messageList...
Route a Message object built from data over the SerialPort communication line to a corresponding MessageListener array designed to handle and interpret the object for processing in the client code .
136,525
@ SuppressWarnings ( "unchecked" ) private void dispatchMessage ( ArrayListMultimap < Integer , MessageListener > listenerMap , Message message ) { List < MessageListener > messageListeners ; if ( message instanceof ChannelMessage ) { messageListeners = listenerMap . get ( ( ( ChannelMessage ) message ) . getChannelInt...
Dispatch a message to the corresponding listener arrays in the listener map
136,526
public Message handleInputStream ( byte commandByte , InputStream inputStream ) { byte firmataCommandByte = commandByte < ( byte ) 0xF0 ? ( byte ) ( commandByte & 0xF0 ) : commandByte ; MessageBuilder messageBuilder = messageBuilderMap . get ( firmataCommandByte ) ; if ( messageBuilder != null ) { byte channelByte = ( ...
Attempts to identify the corresponding Firmata Message object that responds to the given commandByte If found it will ask for the message to be built using given inputStream . The builder will take away any bytes necessary to build the message and then return . To attempt to identify the correct message we must mask th...
136,527
public void messageReceived ( T message ) { if ( responseReceived != null ) { if ( responseReceived ) { log . warn ( "Received more than one synchronous message reply!" ) ; } else { log . warn ( "Received response message after timeout was hit!" ) ; } } responseMessage = message ; responseReceived = true ; synchronized...
When we get our expected message response . Save the message object and notify the waiting thread that the message is now available to be passed back . This method attempts to handle and warn against cases where multiple messages came in or a message came in after the timeout period .
136,528
public Message buildMessage ( Byte channelByte , InputStream inputStream ) { byte sysexCommandByte ; try { sysexCommandByte = ( byte ) inputStream . read ( ) ; } catch ( IOException e ) { log . error ( "Error reading Sysex command byte." ) ; return null ; } ByteArrayOutputStream messageBodyBuilder = new ByteArrayOutput...
Attempts to identify the corresponding Firmata Sysex Message object that responds to the identified sysexCommandByte . If found it will ask for the sysex message to be built using the identified bytes between the sysexCommandByte and the END_SYSEX commandByte later in the input stream .
136,529
public static String sanitize ( String raw ) { return ( raw == null || raw . length ( ) == 0 ) ? raw : HTMLEntityEncode ( canonicalize ( raw ) ) ; }
Sanitize user inputs .
136,530
public static String HTMLEntityEncode ( String input ) { String next = scriptPattern . matcher ( input ) . replaceAll ( "&#x73;cript" ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < next . length ( ) ; ++ i ) { char ch = next . charAt ( i ) ; if ( ch == '<' ) { sb . append ( "&lt;" ) ; } else if ( ch...
Encode HTML entities .
136,531
private void checkEnd ( ) { if ( ended && ! closed && children == 0 ) { closed = true ; connection . doBatchEnd ( id , endArgs ) ; if ( endHandler != null ) { endHandler . handle ( ( Void ) null ) ; } } }
Checks whether the batch is complete .
136,532
void start ( Handler < ConnectionOutputBatch > startHandler ) { connection . doBatchStart ( id , args ) ; this . startHandler = startHandler ; }
Starts the output batch .
136,533
public List < String > getInPorts ( ) { List < String > ports = new ArrayList < > ( ) ; JsonObject jsonPorts = config . getObject ( "ports" ) ; if ( jsonPorts == null ) { return ports ; } JsonArray jsonInPorts = jsonPorts . getArray ( "in" ) ; if ( jsonInPorts == null ) { return ports ; } for ( Object jsonInPort : json...
Returns a list of input ports defined by the module .
136,534
public List < String > getOutPorts ( ) { List < String > ports = new ArrayList < > ( ) ; JsonObject jsonPorts = config . getObject ( "ports" ) ; if ( jsonPorts == null ) { return ports ; } JsonArray jsonOutPorts = jsonPorts . getArray ( "out" ) ; if ( jsonOutPorts == null ) { return ports ; } for ( Object jsonOutPort :...
Returns a list of output ports defined by the module .
136,535
public void fail ( Throwable t ) { if ( ! failed ) { if ( doneHandler != null ) { doneHandler . handle ( new DefaultFutureResult < T > ( t ) ) ; } else { cause = t ; } failed = true ; } }
Indicates that a call failed . This will immediately fail the handler .
136,536
public CountingCompletionHandler < T > setHandler ( Handler < AsyncResult < T > > doneHandler ) { this . doneHandler = doneHandler ; checkDone ( ) ; return this ; }
Sets the completion handler .
136,537
private void checkDone ( ) { if ( doneHandler != null ) { if ( cause != null ) { doneHandler . handle ( new DefaultFutureResult < T > ( cause ) ) ; } else { if ( count == required ) { doneHandler . handle ( new DefaultFutureResult < T > ( ( T ) null ) ) ; } } } }
Checks whether the handler should be called .
136,538
private void setup ( final Handler < AsyncResult < Void > > doneHandler ) { log . debug ( String . format ( "%s - Starting cluster coordination" , DefaultComponent . this ) ) ; coordinator . start ( new Handler < AsyncResult < Void > > ( ) { public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ...
Sets up the component .
136,539
public void start ( ) { input . messageHandler ( new Handler < Object > ( ) { public void handle ( Object message ) { output . send ( message ) ; pumped ++ ; } } ) ; }
Starts the pump .
136,540
public static < T extends Output < T > > Feeder < T > createFeeder ( T output ) { return new Feeder < T > ( output ) ; }
Creates a new feeder .
136,541
private void doFeed ( ) { if ( fed && ! output . sendQueueFull ( ) ) { fed = false ; vertx . runOnContext ( feedRunner ) ; } else { feedTimer = vertx . setTimer ( feedDelay , recursiveRunner ) ; } }
Feeds the next message .
136,542
public static Component createComponent ( Vertx vertx , Container container ) { InstanceContext context = parseContext ( container . config ( ) ) ; return new DefaultComponentFactory ( ) . setVertx ( vertx ) . setContainer ( container ) . createComponent ( context , new DefaultCluster ( context . component ( ) . networ...
Creates a component instance for the current Vert . x instance .
136,543
public static JsonObject buildConfig ( InstanceContext context , Cluster cluster ) { JsonObject config = context . component ( ) . config ( ) . copy ( ) ; return config . putObject ( "__context__" , Contexts . serialize ( context ) ) ; }
Builds a verticle configuration .
136,544
private static InstanceContext parseContext ( JsonObject config ) { JsonObject context = config . getObject ( "__context__" ) ; if ( context == null ) { throw new IllegalArgumentException ( "No component context found." ) ; } config . removeField ( "__context__" ) ; return Contexts . deserialize ( context ) ; }
Parses an instance context from configuration .
136,545
private List < File > locateModules ( ) { File [ ] files = modRoot . listFiles ( ) ; List < File > modFiles = new ArrayList < > ( ) ; for ( File file : files ) { if ( file . isDirectory ( ) ) { boolean isValid = true ; try { new ModuleIdentifier ( file . getName ( ) ) ; } catch ( Exception e ) { isValid = false ; } if ...
Locates all modules in the local repository .
136,546
private File locateModule ( ModuleIdentifier modID ) { File modDir = new File ( modRoot , modID . toString ( ) ) ; if ( modDir . exists ( ) ) { return modDir ; } return null ; }
Locates a module in the modules root directory .
136,547
private void pullInDependencies ( ModuleIdentifier modID , File modDir ) { File modJsonFile = new File ( modDir , MOD_JSON_FILE ) ; ModuleInfo info = loadModuleInfo ( modID , modJsonFile ) ; ModuleFields fields = info . fields ( ) ; List < String > mods = new ArrayList < > ( ) ; String sincludes = fields . getIncludes ...
Pulls in all dependencies for a module .
136,548
private File zipModule ( ModuleIdentifier modID ) { File modDir = new File ( modRoot , modID . toString ( ) ) ; if ( ! modDir . exists ( ) ) { throw new PlatformManagerException ( "Cannot find module" ) ; } File modRoot = new File ( TEMP_DIR , "vertx-zip-mods" ) ; File zipFile = new File ( modRoot , modID . toString ( ...
Creates a zip file from a module .
136,549
private void zipDirectory ( String zipFile , String dirToZip ) { File directory = new File ( dirToZip ) ; try ( ZipOutputStream stream = new ZipOutputStream ( new FileOutputStream ( zipFile ) ) ) { addDirectoryToZip ( directory , directory , stream ) ; } catch ( Exception e ) { throw new PlatformManagerException ( "Fai...
Zips up a directory .
136,550
private void addDirectoryToZip ( File topDirectory , File directory , ZipOutputStream out ) throws IOException { Path top = Paths . get ( topDirectory . getAbsolutePath ( ) ) ; File [ ] files = directory . listFiles ( ) ; byte [ ] buffer = new byte [ BUFFER_SIZE ] ; for ( int i = 0 ; i < files . length ; i ++ ) { Path ...
Recursively adds directories to a zip file .
136,551
private String [ ] parseIncludes ( String sincludes ) { sincludes = sincludes . trim ( ) ; if ( "" . equals ( sincludes ) ) { return null ; } String [ ] arr = sincludes . split ( "," ) ; if ( arr != null ) { for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = arr [ i ] . trim ( ) ; } } return arr ; }
Parses an includes string .
136,552
private void unzipModuleData ( File directory , File zipFile , boolean deleteZip ) { try ( InputStream in = new BufferedInputStream ( new FileInputStream ( zipFile ) ) ; ZipInputStream zin = new ZipInputStream ( new BufferedInputStream ( in ) ) ) { ZipEntry entry ; while ( ( entry = zin . getNextEntry ( ) ) != null ) {...
Unzips a module .
136,553
@ SuppressLint ( "ShowToast" ) public Toast build ( ) { Toast toast = Toast . makeText ( context , message , duration ) ; TextView toastMessage = setupToastView ( toast ) ; setToastMessageTextColor ( toastMessage ) ; setToastGravity ( toast ) ; return toast ; }
Build a Toast using the options specified in the builder .
136,554
private void handleCreate ( final NetworkContext context ) { log . debug ( String . format ( "%s - Network configuration created in cluster: %s" , NetworkManager . this , cluster . address ( ) ) ) ; log . debug ( String . format ( "%s - Scheduling network deployment task" , NetworkManager . this ) ) ; tasks . runTask (...
Handles the creation of the network .
136,555
private void undeployRemovedComponents ( final NetworkContext context , final NetworkContext runningContext , final Handler < AsyncResult < Void > > doneHandler ) { final List < ComponentContext < ? > > removedComponents = new ArrayList < > ( ) ; for ( ComponentContext < ? > runningComponent : runningContext . componen...
Undeploys components that were removed from the network .
136,556
private void handleDelete ( ) { log . debug ( String . format ( "%s - Network configuration removed from cluster: %s" , NetworkManager . this , cluster . address ( ) ) ) ; tasks . runTask ( new Handler < Task > ( ) { public void handle ( final Task task ) { unready ( new Handler < AsyncResult < Void > > ( ) { public vo...
Handles the deletion of the network .
136,557
private void unready ( final Handler < AsyncResult < Void > > doneHandler ) { if ( currentContext != null && data != null ) { log . debug ( String . format ( "%s - Pausing network" , NetworkManager . this ) ) ; data . remove ( currentContext . status ( ) , new Handler < AsyncResult < String > > ( ) { public void handle...
Unreadies the network .
136,558
private void handleReady ( String address ) { log . debug ( String . format ( "%s - Received ready message from %s" , NetworkManager . this , address ) ) ; ready . add ( address ) ; checkReady ( ) ; }
Called when a component instance is ready .
136,559
private void checkReady ( ) { if ( allReady ( ) ) { log . debug ( String . format ( "%s - All components ready in network, starting components" , NetworkManager . this ) ) ; data . put ( currentContext . status ( ) , currentContext . version ( ) , new Handler < AsyncResult < String > > ( ) { public void handle ( AsyncR...
Checks whether the network is ready .
136,560
private void handleUnready ( String address ) { log . debug ( String . format ( "%s - Received unready message from: %s" , NetworkManager . this , address ) ) ; ready . remove ( address ) ; checkUnready ( ) ; }
Called when a component instance is unready .
136,561
private void checkUnready ( ) { if ( ! allReady ( ) ) { log . debug ( String . format ( "%s - Components not ready, pausing components" , NetworkManager . this ) ) ; data . remove ( currentContext . address ( ) , new Handler < AsyncResult < String > > ( ) { public void handle ( AsyncResult < String > result ) { if ( re...
Checks whether the network is unready .
136,562
private boolean allReady ( ) { if ( currentContext == null ) return false ; List < InstanceContext > instances = new ArrayList < > ( ) ; boolean match = true ; outer : for ( ComponentContext < ? > component : currentContext . components ( ) ) { instances . addAll ( component . instances ( ) ) ; for ( InstanceContext in...
Checks whether all components are ready in the network .
136,563
private void deployNetwork ( final NetworkContext context , final Handler < AsyncResult < NetworkContext > > doneHandler ) { log . debug ( String . format ( "%s - Deploying network" , NetworkManager . this ) ) ; final CountingCompletionHandler < Void > complete = new CountingCompletionHandler < Void > ( context . compo...
Deploys a complete network .
136,564
private void deployComponents ( Collection < ComponentContext < ? > > components , final CountingCompletionHandler < Void > counter ) { for ( final ComponentContext < ? > component : components ) { deployComponent ( component , new Handler < AsyncResult < Void > > ( ) { public void handle ( AsyncResult < Void > result ...
Deploys all network components .
136,565
private void deployInstances ( List < InstanceContext > instances , final Handler < AsyncResult < Void > > doneHandler ) { final CountingCompletionHandler < Void > counter = new CountingCompletionHandler < Void > ( instances . size ( ) ) . setHandler ( doneHandler ) ; for ( final InstanceContext instance : instances ) ...
Deploys all network component instances .
136,566
private void deployInstance ( final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { if ( instance . component ( ) . group ( ) != null ) { cluster . getGroup ( instance . component ( ) . group ( ) , new Handler < AsyncResult < Group > > ( ) { public void handle ( AsyncResult < Group > res...
Deploys a single component instance .
136,567
private void deployInstance ( final Node node , final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { data . put ( instance . address ( ) , Contexts . serialize ( instance ) . encode ( ) , new Handler < AsyncResult < String > > ( ) { public void handle ( AsyncResult < String > result ) {...
Deploys an instance to a specific node .
136,568
private void deployModule ( final Node node , final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { log . debug ( String . format ( "%s - Deploying %s to %s" , NetworkManager . this , instance . component ( ) . asModule ( ) . module ( ) , node . address ( ) ) ) ; node . deployModule ( in...
Deploys a module component instance in the network s cluster .
136,569
private void installModules ( final Node node , final NetworkContext context , final Handler < AsyncResult < Void > > doneHandler ) { List < ModuleContext > modules = new ArrayList < > ( ) ; for ( ComponentContext < ? > component : context . components ( ) ) { if ( component . isModule ( ) ) { modules . add ( component...
Installs all modules on a node .
136,570
private void installModule ( final Node node , final ModuleContext module , final Handler < AsyncResult < Void > > doneHandler ) { node . installModule ( module . module ( ) , doneHandler ) ; }
Installs a module on a node .
136,571
private void undeployComponents ( Collection < ComponentContext < ? > > components , final CountingCompletionHandler < Void > complete ) { for ( final ComponentContext < ? > component : components ) { final CountingCompletionHandler < Void > counter = new CountingCompletionHandler < Void > ( component . instances ( ) ....
Undeploys all network components .
136,572
private void undeployInstances ( List < InstanceContext > instances , final CountingCompletionHandler < Void > counter ) { for ( final InstanceContext instance : instances ) { if ( instance . component ( ) . isModule ( ) ) { undeployModule ( instance , counter ) ; } else if ( instance . component ( ) . isVerticle ( ) )...
Undeploys all component instances .
136,573
private void unwatchInstance ( final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { Handler < MapEvent < String , String > > watchHandler = watchHandlers . remove ( instance . address ( ) ) ; if ( watchHandler != null ) { data . unwatch ( instance . status ( ) , watchHandler , new Handl...
Unwatches a component instance s status and context .
136,574
private void undeployModule ( final InstanceContext instance , final CountingCompletionHandler < Void > counter ) { deploymentIDs . remove ( instance . address ( ) , new Handler < AsyncResult < String > > ( ) { public void handle ( AsyncResult < String > result ) { if ( result . failed ( ) ) { counter . fail ( result ....
Undeploys a module component instance .
136,575
private void updateNetwork ( final NetworkContext context , final Handler < AsyncResult < Void > > doneHandler ) { final CountingCompletionHandler < Void > complete = new CountingCompletionHandler < Void > ( context . components ( ) . size ( ) ) ; complete . setHandler ( new Handler < AsyncResult < Void > > ( ) { publi...
Updates a network .
136,576
private void updateComponents ( Collection < ComponentContext < ? > > components , final CountingCompletionHandler < Void > complete ) { for ( final ComponentContext < ? > component : components ) { final CountingCompletionHandler < Void > counter = new CountingCompletionHandler < Void > ( component . instances ( ) . s...
Updates all network components .
136,577
private void updateInstances ( List < InstanceContext > instances , final CountingCompletionHandler < Void > counter ) { for ( final InstanceContext instance : instances ) { data . put ( instance . address ( ) , Contexts . serialize ( instance ) . encode ( ) , new Handler < AsyncResult < String > > ( ) { public void ha...
Updates all component instances .
136,578
private void doNodeJoined ( final Node node ) { tasks . runTask ( new Handler < Task > ( ) { public void handle ( final Task task ) { if ( currentContext != null ) { log . info ( String . format ( "%s - %s joined the cluster. Uploading components to new node" , NetworkManager . this , node . address ( ) ) ) ; installMo...
Handles a node joining the cluster .
136,579
private void doNodeLeft ( final Node node ) { tasks . runTask ( new Handler < Task > ( ) { public void handle ( final Task task ) { if ( currentContext != null ) { log . info ( String . format ( "%s - %s left the cluster. Reassigning components" , NetworkManager . this , node . address ( ) ) ) ; deploymentNodes . keySe...
Handles a node leaving the cluster .
136,580
private void disconnect ( final Handler < AsyncResult < Void > > doneHandler ) { eventBus . sendWithTimeout ( inAddress , new JsonObject ( ) . putString ( "action" , "disconnect" ) , 5000 , new Handler < AsyncResult < Message < Boolean > > > ( ) { public void handle ( AsyncResult < Message < Boolean > > result ) { if (...
Disconnects from the other side of the connection .
136,581
private void checkFull ( ) { if ( ! full && messages . size ( ) >= maxQueueSize ) { full = true ; log . debug ( String . format ( "%s - Connection to %s is full" , this , context . target ( ) ) ) ; } }
Checks whether the connection is full .
136,582
private void checkDrain ( ) { if ( full && ! paused && messages . size ( ) < maxQueueSize / 2 ) { full = false ; log . debug ( String . format ( "%s - Connection to %s is drained" , this , context . target ( ) ) ) ; if ( drainHandler != null ) { drainHandler . handle ( ( Void ) null ) ; } } }
Checks whether the connection has been drained .
136,583
private void doAck ( long id ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Received ack for messages up to %d, removing all previous messages from memory" , this , id ) ) ; } if ( messages . containsKey ( id + 1 ) ) { messages . tailMap ( id + 1 ) ; } else { messages . clear ( ) ; } checkD...
Handles a batch ack .
136,584
private void doFail ( long id ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Received resend request for messages starting at %d" , this , id ) ) ; } doAck ( id ) ; Iterator < Map . Entry < Long , JsonObject > > iter = messages . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ...
Handles a batch fail .
136,585
private void doPause ( long id ) { log . debug ( String . format ( "%s - Paused connection to %s" , this , context . target ( ) ) ) ; paused = true ; }
Handles a connection pause .
136,586
private void doResume ( long id ) { if ( paused ) { log . debug ( String . format ( "%s - Resumed connection to %s" , this , context . target ( ) ) ) ; paused = false ; checkDrain ( ) ; } }
Handles a connection resume .
136,587
void doGroupStart ( String group , String name , Object args , String parent ) { checkOpen ( ) ; JsonObject message = createMessage ( args ) . putString ( "group" , group ) . putString ( "name" , name ) . putString ( "parent" , parent ) . putString ( "action" , "startGroup" ) ; if ( open && ! paused ) { if ( log . isDe...
Sends a group start message .
136,588
void doGroupSend ( String group , Object value ) { checkOpen ( ) ; JsonObject message = createMessage ( value ) . putString ( "action" , "group" ) . putString ( "group" , group ) ; if ( open && ! paused ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Group send: Group[group=%s, id=%d, messag...
Sends a group message .
136,589
void doGroupEnd ( String group , Object args ) { checkOpen ( ) ; JsonObject message = createMessage ( args ) . putString ( "action" , "endGroup" ) . putString ( "group" , group ) ; if ( open && ! paused ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Group end: Group[group=%s, args=%s]" , th...
Sends a group end message .
136,590
void doBatchStart ( String batch , Object args ) { checkOpen ( ) ; JsonObject message = createMessage ( args ) . putString ( "batch" , batch ) . putString ( "action" , "startBatch" ) ; if ( open && ! paused ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Batch start: Batch[batch=%s]" , this ...
Sends a batch start message .
136,591
void doBatchEnd ( String batch , Object args ) { checkOpen ( ) ; JsonObject message = createMessage ( args ) . putString ( "action" , "endBatch" ) . putString ( "batch" , batch ) ; if ( open && ! paused ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "%s - Batch end: Batch[batch=%s, args=%s]" , th...
Sends a batch end message .
136,592
private JsonObject createMessage ( Object value ) { JsonObject message = serializer . serialize ( value ) ; long id = currentMessage ++ ; message . putNumber ( "id" , id ) ; messages . put ( id , message ) ; return message ; }
Creates a value message .
136,593
public static void checkNull ( Object value , String message , Object ... args ) { if ( value != null ) { throw new IllegalArgumentException ( String . format ( message , args ) ) ; } }
Validates that an argument is null .
136,594
public static void checkNotNull ( Object value , String message , Object ... args ) { if ( value == null ) { throw new NullPointerException ( String . format ( message , args ) ) ; } }
Validates that an argument is not null .
136,595
public static void checkPositive ( int number , String message , Object ... args ) { if ( number < 0 ) { throw new IllegalArgumentException ( String . format ( message , args ) ) ; } }
Validates that an argument is positive .
136,596
public static void checkUri ( String uri , String message , Object ... args ) { try { new URI ( uri ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( String . format ( message , args ) , e ) ; } }
Validates that an argument is a valid URI .
136,597
void start ( final Handler < OutputGroup > startHandler ) { connection . doGroupStart ( id , name , args , parent ) ; this . startHandler = startHandler ; }
Starts the output group .
136,598
public static PortLogger getLogger ( Class < ? > clazz , OutputCollector output ) { return getLogger ( clazz . getCanonicalName ( ) , output ) ; }
Creates an output port logger for the given type .
136,599
public static PortLogger getLogger ( String name , OutputCollector output ) { Args . checkNotNull ( name , "logger name cannot be null" ) ; Map < OutputCollector , PortLogger > loggers = PortLoggerFactory . loggers . get ( name ) ; if ( loggers == null ) { loggers = new HashMap < > ( ) ; PortLoggerFactory . loggers . p...
Creates an output port logger with the given name .