//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void startup() throws LifeCycleException public override void startup() { base.startup(); scheduledService = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("RpcTaskScannerThread", true)); scheduledService.scheduleWithFixedDelay(new TempRunnable(scanList), 10000, 10000, TimeUnit.MILLISECONDS); }
public void SendPing() { PingMessage message = new PingMessage(this.node_manager.PublicHomeNode, this.node); this.ping_sequence = message.Timestamp; this.wait_pong = true; this.ping_sent = Helper.CurrentTimeMillis(); SendMessage(message); if (this.node_manager.TimerPong != null && this.node_manager.TimerPong.IsShutdown) { return; } this.node_manager.TimerPong = ScheduledExecutorService.Scheduled(() => { try { if (this.wait_pong) { this.wait_pong = false; HandleTimedOut(); } } catch (System.Exception e) { Logger.Error("Unhandled exception " + e.Message); } }, (int)PingTimeout, (int)PingTimeout); }
public Pusher(Database db, Uri remote, bool continuous, HttpClientFactory clientFactory , ScheduledExecutorService workExecutor) : base(db, remote, continuous, clientFactory , workExecutor) { createTarget = false; observing = false; }
// expected because the old active will be unable to flush the // end-of-segment op since it is fenced /// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> /// <exception cref="Org.Apache.Hadoop.Hdfs.Inotify.MissingEventsException"/> public virtual void TestReadEventsWithTimeout() { Configuration conf = new HdfsConfiguration(); MiniQJMHACluster cluster = new MiniQJMHACluster.Builder(conf).Build(); try { cluster.GetDfsCluster().WaitActive(); cluster.GetDfsCluster().TransitionToActive(0); DFSClient client = new DFSClient(cluster.GetDfsCluster().GetNameNode(0).GetNameNodeAddress (), conf); DFSInotifyEventInputStream eis = client.GetInotifyEventStream(); ScheduledExecutorService ex = Executors.NewSingleThreadScheduledExecutor(); ex.Schedule(new _Runnable_463(client), 1, TimeUnit.Seconds); // test will fail // a very generous wait period -- the edit will definitely have been // processed by the time this is up EventBatch batch = eis.Poll(5, TimeUnit.Seconds); NUnit.Framework.Assert.IsNotNull(batch); NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length); NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType .Create); NUnit.Framework.Assert.AreEqual("/dir", ((Event.CreateEvent)batch.GetEvents()[0]) .GetPath()); } finally { cluster.Shutdown(); } }
public RemoteMultipartRequest(ScheduledExecutorService workExecutor, HttpClientFactory clientFactory, string method, Uri url, MultipartEntity multiPart, IDictionary<string , object> requestHeaders, RemoteRequestCompletionBlock onCompletion) : base(workExecutor , clientFactory, method, url, null, requestHeaders, onCompletion) { this.multiPart = multiPart; }
//------------------------------------------------------------------------- public virtual void test_poll() { AtomicInteger counter = new AtomicInteger(); System.Func <string> pollingFn = () => { switch (counter.incrementAndGet()) { case 1: return(null); case 2: return("Yes"); default: throw new AssertionError("Test failed"); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); CompletableFuture <string> future = Guavate.poll(executor, Duration.ofMillis(100), Duration.ofMillis(100), pollingFn); assertEquals(future.join(), "Yes"); }
public void Init() { this.timer_pool = ScheduledExecutorService.Scheduled(() => { try { FillUp(); } catch (System.Exception e) { Logger.Error("Exception in sync worker", e); } }, 30 * 1000, 3600); this.timer_log = ScheduledExecutorService.Scheduled(() => { try { LogActivePeers(); } catch { } }, 30000, 10000); }
public void Init() { this.fetch_handle = ScheduledExecutorService.Scheduled(() => { try { if (this.is_fetch) { this.is_fetch = false; StartFetchSyncBlock(); } } catch (System.Exception) { Logger.Error("Fetch sync block error."); } }, 10 * 1000, 1 * 1000); this.block_handle = ScheduledExecutorService.Scheduled(() => { try { if (this.is_handle) { this.is_handle = false; HandleSyncBlock(); } } catch (System.Exception) { Logger.Error("Handle sync block error."); } }, 10 * 1000, 1 * 1000); }
public void Init() { if (Args.Instance.IsFastForward) { return; } this.handle_spread = ScheduledExecutorService.Scheduled(() => { try { ConsumerInventoryToSpread(); } catch (System.Exception e) { Logger.Error("Spread thread error. " + e.Message); } }, 100, 30); this.handle_fetch = ScheduledExecutorService.Scheduled(() => { try { ConsumerInventoryToFetch(); } catch (System.Exception e) { Logger.Error("Fetch thread error." + e.Message); } }, 100, 30); }
/// <exception cref="Org.Apache.Hadoop.Lib.Server.ServiceException"/> protected internal override void Init() { int threads = GetServiceConfig().GetInt(ConfThreads, 5); scheduler = new ScheduledThreadPoolExecutor(threads); Log.Debug("Scheduler started"); }
public void Activate(IChannelHandlerContext context) { this.context = context; this.send_message_flag = true; this.executor_handler = ScheduledExecutorService.Scheduled(() => { try { if (this.send_message_flag) { Send(); } } catch (Exception e) { Logger.Error("Unhandled exception " + e.Message); } }, 10, 10); this.thread_send_message = new Thread(new ThreadStart(() => { while (this.send_message_flag) { try { if (this.message_queue.TryDequeue(out Message message)) { this.context.WriteAndFlushAsync(message.GetSendData()).ContinueWith(task => { if (!task.IsCompleted && !this.channel.IsDisconnect) { Logger.Error( string.Format("Fail send to {0}, {1}", this.context.Channel.RemoteAddress, message)); } else { Logger.Debug( string.Format("Send message {0}", message.Type.ToString())); } }); } else { Thread.Sleep(10); continue; } } catch (System.Exception e) { Logger.Error( string.Format("Fail send to {0}, error info: {1}", this.context.Channel.RemoteAddress, e.Message)); } } })) { Name = "SendMsgThread - " + this.context.Channel.RemoteAddress, }; this.thread_send_message.Start(); }
public RemoteMultipartDownloaderRequest(ScheduledExecutorService workExecutor, HttpClientFactory clientFactory, string method, Uri url, object body, Database db, IDictionary <string , object> requestHeaders, RemoteRequestCompletionBlock onCompletion) : base(workExecutor , clientFactory, method, url, body, requestHeaders, onCompletion) { this.db = db; }
public RemoteMultipartRequest(ScheduledExecutorService workExecutor, HttpClientFactory clientFactory, string method, Uri url, MultipartEntity multiPart, IDictionary <string , object> requestHeaders, RemoteRequestCompletionBlock onCompletion) : base(workExecutor , clientFactory, method, url, null, requestHeaders, onCompletion) { this.multiPart = multiPart; }
public virtual void test_poll_exception() { AtomicInteger counter = new AtomicInteger(); System.Func <string> pollingFn = () => { switch (counter.incrementAndGet()) { case 1: return(null); case 2: throw new System.InvalidOperationException("Expected"); default: throw new AssertionError("Test failed"); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); try { CompletableFuture <string> future = Guavate.poll(executor, Duration.ofMillis(100), Duration.ofMillis(100), pollingFn); assertThrows(() => future.join(), typeof(CompletionException), "java.lang.IllegalStateException: Expected"); } finally { executor.shutdown(); } }
//set ui visible// public static void Main(string[] args) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.ScheduledExecutorService scheduler = java.util.concurrent.Executors.newScheduledThreadPool(1); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); EventQueue.invokeLater(new RunnableAnonymousInnerClassHelper(scheduler)); }
public void Start() { this.discover = ScheduledExecutorService.Scheduled( new DiscoverTask(this.node_manager), 1, (int)KademliaOptions.DISCOVER_CYCLE * 1000); this.refresh = ScheduledExecutorService.Scheduled( new RefreshTask(this.node_manager), 1, (int)KademliaOptions.BUCKET_REFRESH); }
/// <summary>Initializes a batcher.</summary> /// <remarks>Initializes a batcher.</remarks> /// <param name="workExecutor">the work executor that performs actual work</param> /// <param name="capacity">The maximum number of objects to batch up. If the queue reaches this size, the queued objects will be sent to the processor immediately. /// </param> /// <param name="delay">The maximum waiting time to collect objects before processing them. In some circumstances objects will be processed sooner. /// </param> /// <param name="processor">The callback/block that will be called to process the objects. /// </param> public Batcher(ScheduledExecutorService workExecutor, int capacity, int delay, BatchProcessor <T> processor) { processNowRunnable = new _Runnable_31(this); this.workExecutor = workExecutor; this.capacity = capacity; this.delay = delay; this.processor = processor; }
/// <summary>Create a new KMSAudit.</summary> /// <param name="windowMs"> /// Duplicate events within the aggregation window are quashed /// to reduce log traffic. A single message for aggregated /// events is printed at the end of the window, along with a /// count of the number of aggregated events. /// </param> internal KMSAudit(long windowMs) { cache = CacheBuilder.NewBuilder().ExpireAfterWrite(windowMs, TimeUnit.Milliseconds ).RemovalListener(new _RemovalListener_118(this)).Build(); executor = Executors.NewScheduledThreadPool(1, new ThreadFactoryBuilder().SetDaemon (true).SetNameFormat(KmsLoggerName + "_thread").Build()); executor.ScheduleAtFixedRate(new _Runnable_132(this), windowMs / 10, windowMs / 10 , TimeUnit.Milliseconds); }
public static ScheduledExecutorService CreateLogSyncer() { ScheduledExecutorService scheduler = Executors.NewSingleThreadScheduledExecutor(new _ThreadFactory_331()); ShutdownHookManager.Get().AddShutdownHook(new _Runnable_340(scheduler), 50); scheduler.ScheduleWithFixedDelay(new _Runnable_347(), 0L, 5L, TimeUnit.Seconds); return(scheduler); }
public override void Init() { lock (this) { _modeSwitcherExecutor = CreateExecutor(); _haCommunicationLife.init(); } }
/// <exception cref="System.Exception"/> protected override void ServiceStart() { if (planFollower != null) { scheduledExecutorService = new ScheduledThreadPoolExecutor(1); scheduledExecutorService.ScheduleWithFixedDelay(planFollower, 0L, planStepSize, TimeUnit .Milliseconds); } base.ServiceStart(); }
/// <exception cref="System.Exception"></exception> public BulkDownloader(ScheduledExecutorService workExecutor, HttpClientFactory clientFactory , Uri dbURL, IList <RevisionInternal> revs, Database database, IDictionary <string , object> requestHeaders, BulkDownloader.BulkDownloaderDocumentBlock onDocument, RemoteRequestCompletionBlock onCompletion) : base(workExecutor, clientFactory, "POST" , new Uri(BuildRelativeURLString(dbURL, "/_bulk_get?revs=true&attachments=true") ), HelperMethod(revs, database), database, requestHeaders, onCompletion) { _db = database; _onDocument = onDocument; }
/// <param name="client">the client</param> /// <param name="path">path to reap children from</param> /// <param name="executor">executor to use for background tasks</param> /// <param name="reapingThresholdMs">threshold in milliseconds that determines that a path can be deleted /// </param> /// <param name="mode">reaping mode</param> /// <param name="leaderPath">if not null, uses a leader selection so that only 1 reaper is active in the cluster /// </param> public ChildReaper(CuratorFramework client, string path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, string leaderPath) { this.client = client; this.mode = mode; this.executor = new CloseableScheduledExecutorService(executor); this.reapingThresholdMs = reapingThresholdMs; this.reaper = new Reaper(client, executor, reapingThresholdMs, leaderPath); AddPath(path); }
public override void Start() { Scheduler = Executors.newSingleThreadScheduledExecutor(daemon("timeout-clusterClient", Monitors.newMonitor(typeof(NamedThreadFactory.Monitor)))); TickFuture = Scheduler.scheduleWithFixedDelay(() => { long now = DateTimeHelper.CurrentUnixTimeMillis(); Server.Timeouts.tick(now); }, 0, 10, TimeUnit.MILLISECONDS); }
public override void HandlerAdded(IChannelHandlerContext context) { this.timer_ping = ScheduledExecutorService.Scheduled(() => { if (!this.has_ping) { this.send_ping_time = Helper.CurrentTimeMillis(); this.has_ping = this.message_quque.SendMessage(new PingMessage()); } }, 10 * 1000, 10 * 1000); }
public void start() { scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("timeout")); scheduler.scheduleWithFixedDelay(() => { long now = DateTimeHelper.CurrentUnixTimeMillis(); _protocolServer.Timeouts.tick(now); }, 0, 10, TimeUnit.MILLISECONDS); }
public virtual void StopReloader() { lock (this) { if (executorService != null) { executorService.ShutdownNow(); executorService = null; } } }
public RemoteRequest(ScheduledExecutorService workExecutor, HttpClientFactory clientFactory , string method, Uri url, object body, IDictionary <string, object> requestHeaders , RemoteRequestCompletionBlock onCompletion) { this.clientFactory = clientFactory; this.method = method; this.url = url; this.body = body; this.onCompletion = onCompletion; this.workExecutor = workExecutor; this.requestHeaders = requestHeaders; }
internal DecommissionManager(Namesystem namesystem, BlockManager blockManager, HeartbeatManager hbManager) { this.namesystem = namesystem; this.blockManager = blockManager; this.hbManager = hbManager; executor = Executors.NewScheduledThreadPool(1, new ThreadFactoryBuilder().SetNameFormat ("DecommissionMonitor-%d").SetDaemon(true).Build()); decomNodeBlocks = new SortedDictionary <DatanodeDescriptor, AbstractList <BlockInfoContiguous > >(); pendingNodes = new List <DatanodeDescriptor>(); }
public override void Init() { _chunkSize = _config.ChunkSize; assertChunkSizeIsWithinFrameSize(_chunkSize, _frameLength); string className = this.GetType().Name; _targetCallExecutor = newCachedThreadPool(named(className + ":" + _config.ServerAddress.Port)); _unfinishedTransactionExecutor = newScheduledThreadPool(2, named("Unfinished transactions")); _silentChannelExecutor = newSingleThreadScheduledExecutor(named("Silent channel reaper")); _silentChannelExecutor.scheduleWithFixedDelay(_connectedSlaveChannels, 5, 5, TimeUnit.SECONDS); }
public virtual void StartReloader() { lock (this) { if (executorService == null) { executorService = Executors.NewScheduledThreadPool(1); executorService.ScheduleAtFixedRate(this, ReloaderSleepMillis, ReloaderSleepMillis , TimeUnit.Milliseconds); } } }
/// <summary> /// Create a new ThreadPoolFace for communication with an NDN hub with the given /// Transport object and connectionInfo. /// </summary> /// /// <param name="threadPool">is also used to schedule the interest timeouts.</param> /// <param name="transport">like AsyncTcpTransport, in which case the transport should use the same ioService.</param> /// <param name="connectionInfo"></param> public ThreadPoolFace(ScheduledExecutorService threadPool, Transport transport, Transport.ConnectionInfo connectionInfo) : base(transport, connectionInfo) { threadPool_ = threadPool; }
/// <param name="scheduledExecutorService"> the service to decorate </param> public CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) : base(scheduledExecutorService, false) { this.scheduledExecutorService = scheduledExecutorService; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeMethod public void setup() public virtual void setup() { executorService = Executors.newScheduledThreadPool(QTY * 2); }
/// <param name="scheduledExecutorService"> the service to decorate </param> /// <param name="shutdownOnClose"> if true, shutdown the executor service when this is closed </param> public CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService, bool shutdownOnClose) : base(scheduledExecutorService, shutdownOnClose) { this.scheduledExecutorService = scheduledExecutorService; }