public class TMasterSink extends java.lang.Object implements IMetricsSink
2. Then it would construct a long-live Service running TMasterClient, which could automatically recover from uncaught exceptions, i.e. close the old one and start a new one. Also, it provides api to update the TMasterLocation that TMasterClient need to connect and restart the TMasterClient. There are two scenarios we need to restart a TMasterClient in our case:
-- Uncaught exceptions happen within TMasterClient; then we would restart TMasterClient inside the same ExecutorService inside the UncaughtExceptionHandlers. Notice that, in java, exceptions occur inside UncaughtExceptionHandlers would not invoke UncaughtExceptionHandlers; instead, it would kill the thread with that exception. So if exceptions thrown during restart a new TMasterClient, this TMasterSink would die, and external logic would take care of it.
-- TMasterLocation changes (though in fact, TMasterClient might also throw exceptions in this case), in this case, we would invoke TMasterService to start from tMasterLocationStarter's thread. But the TMasterService and TMasterClient still start wihtin the thread they run.
3. When a new MetricsRecord comes by invoking processRecord, it would push the MetricsRecord to the Communicator Queue to TMasterClient
Notice that we would not send all metrics to TMaster; we would use MetricsFilter to figure out needed metrics.
Constructor and Description |
---|
TMasterSink() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this stream and releases any system resources associated
with it.
|
protected void |
createSimpleTMasterClientService(java.util.Map<java.lang.String,java.lang.Object> serviceConfig) |
void |
flush()
Flush any buffered metrics
It would be called at an interval according to the configuration
|
protected TopologyMaster.TMasterLocation |
getCurrentTMasterLocation() |
protected TopologyMaster.TMasterLocation |
getCurrentTMasterLocationInService() |
protected TMasterClient |
getTMasterClient() |
protected com.twitter.heron.metricsmgr.sink.tmaster.TMasterSink.TMasterClientService |
getTMasterClientService() |
protected int |
getTMasterStartedAttempts() |
void |
init(java.util.Map<java.lang.String,java.lang.Object> conf,
SinkContext context)
Initialize the MetricsSink
|
void |
processRecord(MetricsRecord record)
Process a metrics record in the sink
|
protected void |
startNewTMasterClient(TopologyMaster.TMasterLocation location) |
public void init(java.util.Map<java.lang.String,java.lang.Object> conf, SinkContext context)
IMetricsSink
init
in interface IMetricsSink
conf
- An unmodifiableMap containing basic configurationcontext
- context objects for Sink to init
Attempts to modify the returned map,
whether direct or via its collection views, result in an UnsupportedOperationException.public void processRecord(MetricsRecord record)
IMetricsSink
processRecord
in interface IMetricsSink
record
- the record to putpublic void flush()
IMetricsSink
flush
in interface IMetricsSink
public void close()
IMetricsSink
close
in interface IMetricsSink
close
in interface java.lang.AutoCloseable
protected com.twitter.heron.metricsmgr.sink.tmaster.TMasterSink.TMasterClientService getTMasterClientService()
protected void createSimpleTMasterClientService(java.util.Map<java.lang.String,java.lang.Object> serviceConfig)
protected TMasterClient getTMasterClient()
protected void startNewTMasterClient(TopologyMaster.TMasterLocation location)
protected int getTMasterStartedAttempts()
protected TopologyMaster.TMasterLocation getCurrentTMasterLocation()
protected TopologyMaster.TMasterLocation getCurrentTMasterLocationInService()