idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
35,500
public Emoji getEmoji ( String unicode ) { Node tree = root ; for ( char c : unicode . toCharArray ( ) ) { if ( ! tree . hasChild ( c ) ) { return null ; } tree = tree . getChild ( c ) ; } return tree . getEmoji ( ) ; }
Finds Emoji instance from emoji unicode
35,501
private String stringJoin ( String [ ] array , int count ) { String joined = "" ; for ( int i = 0 ; i < count ; i ++ ) joined += array [ i ] ; return joined ; }
Method to replace String . join since it was only introduced in java8
35,502
public static boolean isEmoji ( String string ) { if ( string == null ) return false ; EmojiParser . UnicodeCandidate unicodeCandidate = EmojiParser . getNextUnicodeCandidate ( string . toCharArray ( ) , 0 ) ; return unicodeCandidate != null && unicodeCandidate . getEmojiStartIndex ( ) == 0 && unicodeCandidate . getFit...
Tests if a given String is an emoji .
35,503
public BaseWindowedBolt withWindow ( Count windowLength , Duration slidingInterval ) { return withWindowLength ( windowLength ) . withSlidingInterval ( slidingInterval ) ; }
Tuple count and time duration based sliding window configuration .
35,504
public Object getStateOrCreate ( long txid , StateInitializer init ) { if ( _curr . containsKey ( txid ) ) { return _curr . get ( txid ) ; } else { getState ( txid , init ) ; return null ; } }
Returns null if it was created the value otherwise .
35,505
public CheckPointState nextState ( boolean recovering ) { CheckPointState nextState ; switch ( state ) { case PREPARING : nextState = recovering ? new CheckPointState ( txid - 1 , State . COMMITTED ) : new CheckPointState ( txid , State . COMMITTING ) ; break ; case COMMITTING : nextState = new CheckPointState ( txid ,...
Get the next state based on this checkpoint state .
35,506
public Action nextAction ( boolean recovering ) { Action action ; switch ( state ) { case PREPARING : action = recovering ? Action . ROLLBACK : Action . PREPARE ; break ; case COMMITTING : action = Action . COMMIT ; break ; case COMMITTED : action = recovering ? Action . INITSTATE : Action . PREPARE ; break ; default :...
Get the next action to perform based on this checkpoint state .
35,507
public void updateKryoSerializer ( ) { WorkerTopologyContext workerTopologyContext = contextMaker . makeWorkerTopologyContext ( sysTopology ) ; KryoTupleDeserializer kryoTupleDeserializer = new KryoTupleDeserializer ( stormConf , workerTopologyContext , workerTopologyContext . getRawTopology ( ) ) ; KryoTupleSerializer...
create kryo serializer
35,508
public void rebalanceMqList ( ) throws Exception { LOG . info ( "Begin to do rebalance operation" ) ; Set < MessageQueue > newMqs = getMQ ( ) ; Set < MessageQueue > oldMqs = currentOffsets . keySet ( ) ; if ( oldMqs . equals ( newMqs ) == true ) { LOG . info ( "No change of meta queues " + newMqs ) ; return ; } Set < M...
rebalanceMqList must run after commit
35,509
public void addAllBolts ( List < BoltDef > bolts , boolean override ) { for ( BoltDef bolt : bolts ) { String id = bolt . getId ( ) ; if ( this . boltMap . get ( id ) == null || override ) { this . boltMap . put ( bolt . getId ( ) , bolt ) ; } else { LOG . warn ( "Ignoring attempt to create bolt '{}' with override == f...
used by includes implementation
35,510
public TriggerResult onElement ( Object element , long timestamp , TimeWindow window , TriggerContext ctx ) { ctx . registerEventTimeTimer ( window . getEnd ( ) + ctx . getMaxLagMs ( ) , window ) ; return TriggerResult . CONTINUE ; }
If a watermark arrives we need to check all pending windows . If any of the pending window suffices we should fire immediately by registering a timer without delay . Otherwise we register a timer whose time is the window end plus max lag time
35,511
public static String drpcPids ( Map conf ) throws IOException { String ret = drpc_local_dir ( conf ) + FILE_SEPERATEOR + "pids" ; try { FileUtils . forceMkdir ( new File ( ret ) ) ; } catch ( IOException e ) { LOG . error ( "Failed to create dir " + ret , e ) ; throw e ; } return ret ; }
Return drpc s pid dir
35,512
public static Map read_supervisor_topology_conf ( Map conf , String topologyId ) throws IOException { String topologyRoot = StormConfig . supervisor_stormdist_root ( conf , topologyId ) ; String confPath = StormConfig . stormconf_path ( topologyRoot ) ; return ( Map ) readLocalObject ( topologyId , confPath ) ; }
merge storm conf into cluster conf
35,513
private int getNodesForIsolatedTop ( TopologyDetails td , Set < Node > allNodes , NodePool [ ] lesserPools , int nodesRequested ) { String topId = td . getId ( ) ; LOG . debug ( "Topology {} is isolated" , topId ) ; int nodesFromUsAvailable = nodesAvailable ( ) ; int nodesFromOthersAvailable = NodePool . nodesAvailable...
Get the nodes needed to schedule an isolated topology .
35,514
private int getNodesForNotIsolatedTop ( TopologyDetails td , Set < Node > allNodes , NodePool [ ] lesserPools ) { String topId = td . getId ( ) ; LOG . debug ( "Topology {} is not isolated" , topId ) ; int totalTasks = td . getExecutors ( ) . size ( ) ; int origRequest = td . getNumWorkers ( ) ; int slotsRequested = Ma...
Get the nodes needed to schedule a non - isolated topology .
35,515
boolean tryAdd ( TaskMessage taskMsg ) { if ( ( encodedLength + msgEncodeLength ( taskMsg ) ) > buffer_size ) return false ; add ( taskMsg ) ; return true ; }
try to add a TaskMessage to a batch
35,516
private void writeTaskMessage ( ChannelBufferOutputStream bout , TaskMessage message ) throws Exception { int payload_len = 0 ; if ( message . message ( ) != null ) payload_len = message . message ( ) . length ; short type = message . get_type ( ) ; bout . writeShort ( type ) ; int task_id = message . task ( ) ; if ( t...
write a TaskMessage into a stream
35,517
public final AtomicOutputStream createBlob ( String key , SettableBlobMeta meta ) throws KeyAlreadyExistsException { return createBlobToExtend ( key , meta ) ; }
Client facing API to create a blob .
35,518
public final void setBlobMeta ( String key , SettableBlobMeta meta ) throws AuthorizationException , KeyNotFoundException { setBlobMetaToExtend ( key , meta ) ; }
Client facing API to set the metadata for a blob .
35,519
public static boolean downloadMissingBlob ( Map conf , BlobStore blobStore , String key , Set < NimbusInfo > nimbusInfos ) throws TTransportException { NimbusClient client ; ReadableBlobMeta rbm ; ClientBlobStore remoteBlobStore ; InputStreamWithMeta in ; boolean isSuccess = false ; LOG . debug ( "Download blob NimbusI...
Download missing blobs from potential nimbodes
35,520
public static boolean downloadUpdatedBlob ( Map conf , BlobStore blobStore , String key , Set < NimbusInfo > nimbusInfos ) throws TTransportException { NimbusClient client ; ClientBlobStore remoteBlobStore ; boolean isSuccess = false ; LOG . debug ( "Download blob NimbusInfos {}" , nimbusInfos ) ; for ( NimbusInfo nimb...
Download updated blobs from potential nimbodes
35,521
public static List < String > getKeyListFromBlobStore ( BlobStore blobStore ) throws Exception { Iterator < String > keys = blobStore . listKeys ( ) ; List < String > keyList = new ArrayList < String > ( ) ; if ( keys != null ) { while ( keys . hasNext ( ) ) { keyList . add ( keys . next ( ) ) ; } } LOG . debug ( "KeyL...
Get the list of keys from blobstore
35,522
public static < R > Set < R > filterAndListKeys ( Iterator < R > keys , KeyFilter < R > filter ) { Set < R > ret = new HashSet < R > ( ) ; while ( keys . hasNext ( ) ) { R key = keys . next ( ) ; R filtered = filter . filter ( key ) ; if ( filtered != null ) { ret . add ( filtered ) ; } } return ret ; }
Filters keys based on the KeyFilter passed as the argument .
35,523
public static void cleanup_key ( String blobKey , BlobStore blobStore , StormClusterState clusterState ) { if ( blobKey . startsWith ( JStormMetrics . NIMBUS_METRIC_KEY ) || blobKey . startsWith ( JStormMetrics . CLUSTER_METRIC_KEY ) || blobKey . startsWith ( JStormMetrics . SUPERVISOR_METRIC_KEY ) ) { return ; } try {...
remove blob information in zk for the blobkey
35,524
public static void downloadDistributeStormCode ( Map conf , String topologyId , String masterCodeDir ) throws IOException , TException { String tmpToot = null ; try { tmpToot = StormConfig . supervisorTmpDir ( conf ) + File . separator + UUID . randomUUID ( ) . toString ( ) ; String stormRoot = StormConfig . supervisor...
no need to synchronize since EventManager will execute sequentially
35,525
public static boolean setLogBackLevel ( String loggerName , String logLevel ) { String logLevelUpper = ( logLevel == null ) ? "OFF" : logLevel . toUpperCase ( ) ; try { Package logbackPackage = Package . getPackage ( LOGBACK_CLASSIC ) ; if ( logbackPackage == null ) { LOG . warn ( "Logback is not in the classpath!" ) ;...
Dynamically sets the logback log level for the given class to the specified level .
35,526
public static boolean setLog4jLevel ( String loggerName , String logLevel ) { String logLevelUpper = ( logLevel == null ) ? "OFF" : logLevel . toUpperCase ( ) ; try { Package log4jPackage = Package . getPackage ( LOG4J_CLASSIC ) ; if ( log4jPackage == null ) { LOG . warn ( "Log4j is not in the classpath!" ) ; return fa...
Dynamically sets the log4j log level for the given class to the specified level .
35,527
public static int deserializeTaskId ( byte [ ] ser ) { Input _kryoInput = new Input ( 1 ) ; _kryoInput . setBuffer ( ser ) ; return _kryoInput . readInt ( ) ; }
just get target taskId
35,528
public static boolean isPortAvailable ( int port ) { try { ServerSocket socket = new ServerSocket ( port ) ; socket . close ( ) ; return true ; } catch ( IOException e ) { return false ; } }
See if a port is available for listening on by trying to listen on it and seeing if that works or fails .
35,529
public static boolean isPortAvailable ( String host , int port ) { try { Socket socket = new Socket ( host , port ) ; socket . close ( ) ; return false ; } catch ( IOException e ) { return true ; } }
See if a port is available for listening on by trying connect to it and seeing if that works or fails
35,530
public static Configuration patchConfiguration ( Configuration conf ) { if ( conf . get ( JstormXmlConfKeys . IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH ) == null ) { conf . set ( JstormXmlConfKeys . IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH , "true" ) ; } return conf ; }
Take an existing conf and patch it for needs . Useful in Service . init & RunService methods where a shared config is being passed in
35,531
public static List < String > collectionToStringList ( Collection c ) { List < String > l = new ArrayList < String > ( c . size ( ) ) ; for ( Object o : c ) { l . add ( o . toString ( ) ) ; } return l ; }
Take a collection return a list containing the string value of every element in the collection .
35,532
public static String join ( Collection collection , String separator ) { return join ( collection , separator , true ) ; }
Join an collection of objects with a separator that appears after every instance in the list - including at the end
35,533
public static String join ( Collection collection , String separator , boolean trailing ) { StringBuilder b = new StringBuilder ( ) ; if ( collection . isEmpty ( ) ) { return trailing ? separator : "" ; } for ( Object o : collection ) { b . append ( o ) ; b . append ( separator ) ; } int length = separator . length ( )...
Join an collection of objects with a separator that appears after every instance in the list - optionally at the end
35,534
public static String join ( String [ ] collection , String separator , boolean trailing ) { return join ( Arrays . asList ( collection ) , separator , trailing ) ; }
Join an array of strings with a separator that appears after every instance in the list - optionally at the end
35,535
public static String joinWithInnerSeparator ( String separator , Object ... collection ) { StringBuilder b = new StringBuilder ( ) ; boolean first = true ; for ( Object o : collection ) { if ( first ) { first = false ; } else { b . append ( separator ) ; } b . append ( o . toString ( ) ) ; b . append ( separator ) ; } ...
Join an array of strings with a separator that appears after every instance in the list - except at the end
35,536
public static String getSupervisorSlotPorts ( int memory , int vcores , String instanceName , String supervisorHost , RegistryOperations registryOperations ) { return join ( getSupervisorPorts ( memory , vcores , instanceName , supervisorHost , registryOperations ) , JOYConstants . COMMA , false ) ; }
this is for jstorm configuration s format
35,537
private long getNextAlignedWindowTs ( long startTs , long endTs ) { long nextTs = windowManager . getEarliestEventTs ( startTs , endTs ) ; if ( nextTs == Long . MAX_VALUE || ( nextTs % slidingIntervalMs == 0 ) ) { return nextTs ; } return nextTs + ( slidingIntervalMs - ( nextTs % slidingIntervalMs ) ) ; }
Computes the next window by scanning the events in the window and finds the next aligned window between the startTs and endTs . Return the end ts of the next aligned window i . e . the ts when the window should fire .
35,538
private long computeWaterMarkTs ( ) { long ts = 0 ; if ( streamToTs . size ( ) >= inputStreams . size ( ) ) { ts = Long . MAX_VALUE ; for ( Map . Entry < GlobalStreamId , Long > entry : streamToTs . entrySet ( ) ) { ts = Math . min ( ts , entry . getValue ( ) ) ; } } return ts - eventTsLag ; }
Computes the min ts across all streams .
35,539
public static String topologyIdToName ( String topologyId ) throws InvalidTopologyException { String ret ; int index = topologyId . lastIndexOf ( '-' ) ; if ( index != - 1 && index > 2 ) { index = topologyId . lastIndexOf ( '-' , index - 1 ) ; if ( index != - 1 && index > 0 ) ret = topologyId . substring ( 0 , index ) ...
Convert topologyId to topologyName . TopologyId = topoloygName - counter - timeStamp
35,540
public static boolean charValidate ( String name ) { if ( name . matches ( "[0-9]+" ) || name . toLowerCase ( ) . equals ( "null" ) ) { return false ; } else { return name . matches ( "[a-zA-Z0-9-_.]+" ) ; } }
Validation of topology name chars . Only alpha char number - _ . are valid .
35,541
@ SuppressWarnings ( "unchecked" ) public static void validate_ids ( StormTopology topology , String topologyId ) throws InvalidTopologyException { String topologyName = topologyIdToName ( topologyId ) ; if ( ! charValidate ( topologyName ) ) { throw new InvalidTopologyException ( topologyName + " is not a valid topolo...
Check Whether ID of Bolt or spout is system_id
35,542
public static void add_acker ( Map stormConf , StormTopology ret ) { String key = Config . TOPOLOGY_ACKER_EXECUTORS ; Integer ackerNum = JStormUtils . parseInt ( stormConf . get ( key ) , 0 ) ; HashMap < String , StreamInfo > outputs = new HashMap < > ( ) ; ArrayList < String > fields = new ArrayList < > ( ) ; fields ....
Add acker bolt to topology
35,543
@ SuppressWarnings ( "unchecked" ) public static Map component_conf ( TopologyContext topology_context , String component_id ) { Map < Object , Object > componentConf = new HashMap < > ( ) ; String jconf = topology_context . getComponentCommon ( component_id ) . get_json_conf ( ) ; if ( jconf != null ) { componentConf ...
get component configuration
35,544
public static Object get_task_object ( StormTopology topology , String component_id , URLClassLoader loader ) { Map < String , SpoutSpec > spouts = topology . get_spouts ( ) ; Map < String , Bolt > bolts = topology . get_bolts ( ) ; Map < String , StateSpoutSpec > state_spouts = topology . get_state_spouts ( ) ; Compon...
get object of component_id
35,545
public static Map getComponentMap ( DefaultTopologyAssignContext context , Integer task ) { String componentName = context . getTaskToComponent ( ) . get ( task ) ; ComponentCommon componentCommon = ThriftTopologyUtils . getComponentCommon ( context . getSysTopology ( ) , componentName ) ; Map componentMap = ( Map ) JS...
get the component s configuration
35,546
public Integer get_version ( String path , boolean watch ) throws Exception { return zkObj . getVersion ( zk , path , watch ) ; }
Note that get_version doesn t use zkCache avoid to conflict with get_data
35,547
public void activate ( String topologyName ) throws TException { try { NimbusUtils . transitionName ( data , topologyName , true , StatusType . activate ) ; notifyTopologyActionListener ( topologyName , "activate" ) ; } catch ( NotAliveException e ) { String errMsg = "Activate Error, topology " + topologyName + " is no...
set topology status as active
35,548
public void rebalance ( String topologyName , RebalanceOptions options ) throws TException { try { checkTopologyActive ( data , topologyName , true ) ; Integer wait_amt = null ; String jsonConf = null ; Boolean reassign = false ; if ( options != null ) { if ( options . is_set_wait_secs ( ) ) wait_amt = options . get_wa...
rebalance a topology
35,549
public String beginFileUpload ( ) throws TException { String fileLoc = null ; try { String path ; String key = UUID . randomUUID ( ) . toString ( ) ; path = StormConfig . masterInbox ( conf ) + "/" + key ; FileUtils . forceMkdir ( new File ( path ) ) ; FileUtils . cleanDirectory ( new File ( path ) ) ; fileLoc = path +...
prepare to upload topology jar return the file location
35,550
public void uploadChunk ( String location , ByteBuffer chunk ) throws TException { TimeCacheMap < Object , Object > uploaders = data . getUploaders ( ) ; Object obj = uploaders . get ( location ) ; if ( obj == null ) { throw new TException ( "File for that location does not exist (or timed out) " + location ) ; } try {...
upload topology jar data
35,551
public ClusterSummary getClusterInfo ( ) throws TException { long start = System . nanoTime ( ) ; try { StormClusterState stormClusterState = data . getStormClusterState ( ) ; Map < String , Assignment > assignments = new HashMap < > ( ) ; List < TopologySummary > topologySummaries = NimbusUtils . getTopologySummary ( ...
get cluster s summary it will contain SupervisorSummary and TopologySummary
35,552
public String getTopologyConf ( String id ) throws TException { String rtn ; try { Map < Object , Object > topologyConf = StormConfig . read_nimbus_topology_conf ( id , data . getBlobStore ( ) ) ; rtn = JStormUtils . to_json ( topologyConf ) ; } catch ( IOException e ) { LOG . info ( "Failed to get configuration of " +...
get topology configuration
35,553
public StormTopology getTopology ( String id ) throws TException { StormTopology topology ; try { StormTopology stormtopology = StormConfig . read_nimbus_topology_code ( id , data . getBlobStore ( ) ) ; if ( stormtopology == null ) { throw new NotAliveException ( "No topology of " + id ) ; } Map < Object , Object > top...
get StormTopology throw deserialize local files
35,554
public void checkTopologyActive ( NimbusData nimbus , String topologyName , boolean bActive ) throws Exception { if ( isTopologyActive ( nimbus . getStormClusterState ( ) , topologyName ) != bActive ) { if ( bActive ) { throw new NotAliveException ( topologyName + " is not alive" ) ; } else { throw new AlreadyAliveExce...
check whether the topology is bActive?
35,555
public boolean isTopologyActive ( StormClusterState stormClusterState , String topologyName ) throws Exception { boolean rtn = false ; if ( Cluster . get_topology_id ( stormClusterState , topologyName ) != null ) { rtn = true ; } return rtn ; }
whether the topology is active by topology name
35,556
public static ArrayList < Path > listFilesByModificationTime ( FileSystem fs , Path directory , long olderThan ) throws IOException { ArrayList < LocatedFileStatus > fstats = new ArrayList < > ( ) ; RemoteIterator < LocatedFileStatus > itr = fs . listFiles ( directory , false ) ; while ( itr . hasNext ( ) ) { LocatedFi...
list files sorted by modification time that have not been modified since olderThan . if olderThan is < = 0 then the filtering is disabled
35,557
public static FSDataOutputStream tryCreateFile ( FileSystem fs , Path file ) throws IOException { try { FSDataOutputStream os = fs . create ( file , false ) ; return os ; } catch ( FileAlreadyExistsException e ) { return null ; } catch ( RemoteException e ) { if ( e . unwrapRemoteException ( ) instanceof AlreadyBeingCr...
Returns null if file already exists . throws if there was unexpected problem
35,558
public SpoutDeclarer setSpoutWithAck ( String id , IRichSpout spout , Number parallelismHint ) { return setSpout ( id , new AckTransactionSpout ( spout ) , parallelismHint ) ; }
Build spout to provide the compatibility with Storm s ack mechanism
35,559
public BoltDeclarer setBoltWithAck ( String id , IRichBolt bolt , Number parallelismHint ) { return setBolt ( id , new AckTransactionBolt ( bolt ) , parallelismHint ) ; }
Build bolt to provide the compatibility with Storm s ack mechanism
35,560
@ SuppressWarnings ( "rawtypes" ) public void prepare ( Map stormConf ) { this . stormConf = stormConf ; int maxWorkers = Utils . getInt ( stormConf . get ( Config . STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS ) ) ; ThreadFactory bossFactory = new NettyRenameThreadFactory ( MetricDef . NETTY_CLI + "boss" ) ; ThreadFact...
initialization per Storm configuration
35,561
public void assign ( WorkerSlot slot , Collection < ExecutorDetails > executors ) { for ( ExecutorDetails executor : executors ) { this . executorToSlot . put ( executor , slot ) ; } }
Assign the slot to executors .
35,562
public void unassignBySlot ( WorkerSlot slot ) { List < ExecutorDetails > executors = new ArrayList < > ( ) ; for ( ExecutorDetails executor : this . executorToSlot . keySet ( ) ) { WorkerSlot ws = this . executorToSlot . get ( executor ) ; if ( ws . equals ( slot ) ) { executors . add ( executor ) ; } } for ( Executor...
Release the slot occupied by this assignment .
35,563
private void handleWaterMarkEvent ( Event < T > waterMarkEvent ) { long watermarkTs = waterMarkEvent . getTimestamp ( ) ; List < Long > eventTs = windowManager . getSlidingCountTimestamps ( lastProcessedTs , watermarkTs , count ) ; for ( long ts : eventTs ) { evictionPolicy . setContext ( ts ) ; handler . onTrigger ( )...
Triggers all the pending windows up to the waterMarkEvent timestamp based on the sliding interval count .
35,564
public TTransport connect ( TTransport transport , String serverHost , String asUser ) throws TTransportException { int maxBufferSize = type . getMaxBufferSize ( storm_conf ) ; TTransport conn = new TFramedTransport ( transport , maxBufferSize ) ; conn . open ( ) ; LOG . debug ( "Simple client transport has been establ...
Connect to the specified server via framed transport
35,565
public synchronized void registerSignal ( int signalNumber , Runnable callback , boolean replace ) { String signalName = signalMap . get ( signalNumber ) ; if ( signalName == null ) { LOG . warn ( "Invalid signalNumber " + signalNumber ) ; return ; } LOG . info ( "Begin to register signal of {}" , signalName ) ; try { ...
Register signal to system if callback is null then the current process will ignore this signal
35,566
public List < Integer > get ( Integer out_task_id , String stream , List < Object > tuple , Collection < Tuple > anchors , Object root_id ) { if ( isDebug ( anchors , root_id ) ) { LOG . info ( debugIdStr + stream + " to " + out_task_id + ":" + tuple ) ; } taskStats . send_tuple ( stream , 1 ) ; List < Integer > out_ta...
direct send tuple to special task
35,567
public List < Integer > get ( String stream , List < Object > tuple , Collection < Tuple > anchors , Object rootId ) { List < Integer > outTasks = new ArrayList < > ( ) ; Map < String , MkGrouper > componentCrouping = streamComponentGrouper . get ( stream ) ; if ( componentCrouping == null ) { LOG . debug ( "Failed to ...
send tuple according to grouping
35,568
public static AsmMetric find ( String name ) { for ( AsmMetricRegistry registry : allRegistries ) { AsmMetric metric = registry . getMetric ( name ) ; if ( metric != null ) { return metric ; } } return null ; }
reserve for debug purposes
35,569
public static AsmHistogram registerWorkerHistogram ( String topologyId , String name , AsmHistogram histogram ) { return ( AsmHistogram ) registerWorkerMetric ( MetricUtils . workerMetricName ( topologyId , host , 0 , name , MetricType . HISTOGRAM ) , histogram ) ; }
simplified helper method to register a worker histogram
35,570
public static AsmGauge registerWorkerGauge ( String topologyId , String name , AsmGauge gauge ) { return ( AsmGauge ) registerWorkerMetric ( MetricUtils . workerMetricName ( topologyId , host , 0 , name , MetricType . GAUGE ) , gauge ) ; }
simplified helper method to register a worker gauge
35,571
public static AsmMeter registerWorkerMeter ( String topologyId , String name , AsmMeter meter ) { return ( AsmMeter ) registerWorkerMetric ( MetricUtils . workerMetricName ( topologyId , host , 0 , name , MetricType . METER ) , meter ) ; }
simplified helper method to register a worker meter
35,572
public static AsmCounter registerWorkerCounter ( String topologyId , String name , AsmCounter counter ) { return ( AsmCounter ) registerWorkerMetric ( MetricUtils . workerMetricName ( topologyId , host , 0 , name , MetricType . COUNTER ) , counter ) ; }
simplified helper method to register a worker counter
35,573
public static void killProcess ( String pid ) { synchronized ( lock ) { LOG . info ( "Begin to kill process " + pid ) ; WorkerShutdown shutdownHandle = getProcessHandle ( pid ) ; if ( shutdownHandle != null ) { shutdownHandle . shutdown ( ) ; } processMap . remove ( pid ) ; LOG . info ( "Successfully killed process " +...
Kill a process
35,574
private void loginHadoopUser ( Subject subject ) { Class < ? > ugi = null ; try { ugi = Class . forName ( "org.apache.hadoop.security.UserGroupInformation" ) ; } catch ( ClassNotFoundException e ) { LOG . info ( "Hadoop was not found on the class path" ) ; return ; } try { Method isSecEnabled = ugi . getMethod ( "isSec...
Hadoop does not just go off of a TGT it needs a bit more . This should fill in the rest .
35,575
public void update ( Map conf ) { for ( IUpdater updater : updaters ) { try { updater . update ( conf ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; } } }
trigger all updaters update action
35,576
public static String stream2taskName ( String old ) { String [ ] parts = old . split ( DELIM ) ; if ( parts . length >= 7 ) { parts [ 0 ] = MetaType . TASK . getV ( ) + parts [ 0 ] . charAt ( 1 ) ; parts [ parts . length - 3 ] = EMPTY ; String metricName = getMergeMetricName ( parts [ parts . length - 1 ] ) ; parts [ p...
make streamId empty remain other parts the same
35,577
public static String task2compName ( String old ) { String [ ] parts = old . split ( DELIM ) ; if ( parts . length >= 7 ) { parts [ 0 ] = MetaType . COMPONENT . getV ( ) + parts [ 0 ] . charAt ( 1 ) ; parts [ parts . length - 3 ] = EMPTY ; parts [ parts . length - 4 ] = "0" ; } return concat ( parts ) ; }
make taskId = 0 and streamId empty .
35,578
public static String stream2compStreamName ( String old ) { String [ ] parts = old . split ( DELIM ) ; if ( parts . length >= 7 ) { parts [ 0 ] = MetaType . COMPONENT_STREAM . getV ( ) + parts [ 0 ] . charAt ( 1 ) ; parts [ parts . length - 4 ] = "0" ; parts [ parts . length - 1 ] = getMergeMetricName ( parts [ parts ....
converts a task metric name to a component - level stream metric name
35,579
public static String task2MergeCompName ( String old ) { String [ ] parts = old . split ( DELIM ) ; if ( parts . length >= 7 ) { parts [ 0 ] = MetaType . COMPONENT . getV ( ) + parts [ 0 ] . charAt ( 1 ) ; parts [ parts . length - 3 ] = EMPTY ; parts [ parts . length - 4 ] = "0" ; String metricName = getMergeMetricName...
make taskId = 0 and streamId empty and metricName remain the string after . .
35,580
public static String comp2topologyName ( String old ) { String [ ] parts = old . split ( DELIM ) ; parts [ 0 ] = MetaType . TOPOLOGY . getV ( ) + parts [ 0 ] . charAt ( 1 ) ; return concat ( parts [ 0 ] , parts [ 1 ] , EMPTY , "0" , parts [ 5 ] , parts [ 6 ] ) ; }
change component metric name to topology metric name
35,581
public static Configuration GetConfiguration ( Map storm_conf ) { Configuration login_conf = null ; String loginConfigurationFile = ( String ) storm_conf . get ( "java.security.auth.login.config" ) ; if ( ( loginConfigurationFile != null ) && ( loginConfigurationFile . length ( ) > 0 ) ) { File config_file = new File (...
Construct a JAAS configuration object per storm configuration file
35,582
public static IPrincipalToLocal GetPrincipalToLocalPlugin ( Map storm_conf ) { IPrincipalToLocal ptol = null ; try { String ptol_klassName = ( String ) storm_conf . get ( Config . STORM_PRINCIPAL_TO_LOCAL_PLUGIN ) ; Class klass = Class . forName ( ptol_klassName ) ; ptol = ( IPrincipalToLocal ) klass . newInstance ( ) ...
Construct a principal to local plugin
35,583
public static IGroupMappingServiceProvider GetGroupMappingServiceProviderPlugin ( Map storm_conf ) { IGroupMappingServiceProvider gmsp = null ; try { String gmsp_klassName = ( String ) storm_conf . get ( Config . STORM_GROUP_MAPPING_SERVICE_PROVIDER_PLUGIN ) ; Class klass = Class . forName ( gmsp_klassName ) ; gmsp = (...
Construct a group mapping service provider plugin
35,584
public static Collection < ICredentialsRenewer > GetCredentialRenewers ( Map conf ) { try { Set < ICredentialsRenewer > ret = new HashSet < ICredentialsRenewer > ( ) ; Collection < String > clazzes = ( Collection < String > ) conf . get ( Config . NIMBUS_CREDENTIAL_RENEWERS ) ; if ( clazzes != null ) { for ( String cla...
Get all of the configured Credential Renwer Plugins .
35,585
public static Collection < INimbusCredentialPlugin > getNimbusAutoCredPlugins ( Map conf ) { try { Set < INimbusCredentialPlugin > ret = new HashSet < INimbusCredentialPlugin > ( ) ; Collection < String > clazzes = ( Collection < String > ) conf . get ( Config . NIMBUS_AUTO_CRED_PLUGINS ) ; if ( clazzes != null ) { for...
Get all the Nimbus Auto cred plugins .
35,586
public static Collection < IAutoCredentials > GetAutoCredentials ( Map storm_conf ) { try { Set < IAutoCredentials > autos = new HashSet < IAutoCredentials > ( ) ; Collection < String > clazzes = ( Collection < String > ) storm_conf . get ( Config . TOPOLOGY_AUTO_CREDENTIALS ) ; if ( clazzes != null ) { for ( String cl...
Get all of the configured AutoCredential Plugins .
35,587
public static Subject populateSubject ( Subject subject , Collection < IAutoCredentials > autos , Map < String , String > credentials ) { try { if ( subject == null ) { subject = new Subject ( ) ; } for ( IAutoCredentials autoCred : autos ) { autoCred . populateSubject ( subject , credentials ) ; } return subject ; } c...
Populate a subject from credentials using the IAutoCredentials .
35,588
public static ITransportPlugin GetTransportPlugin ( ThriftConnectionType type , Map storm_conf , Configuration login_conf ) { ITransportPlugin transportPlugin = null ; try { String transport_plugin_klassName = type . getTransportPlugin ( storm_conf ) ; Class klass = Class . forName ( transport_plugin_klassName ) ; tran...
Construct a transport plugin per storm configuration
35,589
public static IHttpCredentialsPlugin GetUiHttpCredentialsPlugin ( Map conf ) { String klassName = ( String ) conf . get ( Config . UI_HTTP_CREDS_PLUGIN ) ; return AuthUtils . GetHttpCredentialsPlugin ( conf , klassName ) ; }
Construct an HttpServletRequest credential plugin specified by the UI storm configuration
35,590
public static IHttpCredentialsPlugin GetDrpcHttpCredentialsPlugin ( Map conf ) { String klassName = ( String ) conf . get ( Config . DRPC_HTTP_CREDS_PLUGIN ) ; return AuthUtils . GetHttpCredentialsPlugin ( conf , klassName ) ; }
Construct an HttpServletRequest credential plugin specified by the DRPC storm configuration
35,591
private boolean increment ( TridentCollector [ ] lengths , int [ ] indices , int j ) { if ( j == - 1 ) return false ; indices [ j ] ++ ; CaptureCollector capturer = ( CaptureCollector ) lengths [ j ] ; if ( indices [ j ] >= capturer . captured . size ( ) ) { indices [ j ] = 0 ; return increment ( lengths , indices , j ...
return false if can t increment anymore
35,592
public void doReconnect ( ) { if ( channelRef . get ( ) != null ) { return ; } if ( isClosed ( ) ) { return ; } if ( isConnecting . getAndSet ( true ) ) { LOG . info ( "Connect twice {}" , name ( ) ) ; return ; } long sleepMs = getSleepTimeMs ( ) ; LOG . info ( "Reconnect ... [{}], {}, sleep {}ms" , retries . get ( ) ,...
The function can t be synchronized otherwise it will cause deadlock
35,593
void closeChannel ( final Channel channel ) { synchronized ( channelClosing ) { if ( closingChannel . contains ( channel ) ) { LOG . info ( channel . toString ( ) + " has already been closed" ) ; return ; } closingChannel . add ( channel ) ; } LOG . debug ( channel . toString ( ) + " begin to close" ) ; ChannelFuture c...
Avoid channel double close
35,594
public void onEvent ( Object event , long sequence , boolean endOfBatch ) throws Exception { try { if ( event == null ) { return ; } Runnable runnable = null ; if ( event instanceof Tuple ) { if ( ( ( TupleExt ) event ) . isBatchTuple ( ) ) { List < Object > values = ( ( Tuple ) event ) . getValues ( ) ; for ( Object v...
Handle acker message
35,595
private KeyValueState < String , CheckPointState > loadCheckpointState ( Map conf , TopologyContext ctx ) { String namespace = ctx . getThisComponentId ( ) + "-" + ctx . getThisTaskId ( ) ; KeyValueState < String , CheckPointState > state = ( KeyValueState < String , CheckPointState > ) StateFactory . getState ( namesp...
Loads the last saved checkpoint state the from persistent storage .
35,596
@ SuppressWarnings ( "unchecked" ) private void checkNeedUpdateTopologies ( Map < String , StateHeartbeat > localWorkerStats , Map < Integer , LocalAssignment > localAssignments ) throws Exception { Set < String > topologies = new HashSet < > ( ) ; for ( Map . Entry < Integer , LocalAssignment > entry : localAssignment...
check all workers is failed or not
35,597
public void markAllNewWorkers ( Map < Integer , String > workerIds ) { int startTime = TimeUtils . current_time_secs ( ) ; for ( Entry < Integer , String > entry : workerIds . entrySet ( ) ) { String oldWorkerIds = portToWorkerId . get ( entry . getKey ( ) ) ; if ( oldWorkerIds != null ) { workerIdToStartTimeAndPort . ...
mark all new Workers like 52b11418 - 7474 - 446d - bff5 - 0ecd68f4954f
35,598
public void checkNewWorkers ( Map conf ) throws IOException , InterruptedException { Set < String > workers = new HashSet < > ( ) ; for ( Entry < String , Pair < Integer , Integer > > entry : workerIdToStartTimeAndPort . entrySet ( ) ) { String workerId = entry . getKey ( ) ; int startTime = entry . getValue ( ) . getF...
check whether timestamp of new workers is not > SUPERVISOR_WORKER_START_TIMEOUT_SECS otherwise mark as failed
35,599
public boolean matchesAssignment ( WorkerHeartbeat whb , Map < Integer , LocalAssignment > assignedTasks ) { boolean isMatch = true ; LocalAssignment localAssignment = assignedTasks . get ( whb . getPort ( ) ) ; if ( localAssignment == null ) { LOG . debug ( "Following worker has been removed, port=" + whb . getPort ( ...
check whether the worker heartbeat is allowed in the assignedTasks