//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public void queuePush(org.neo4j.kernel.ha.com.master.Slave slave, final long txId) public virtual void QueuePush(Slave slave, long txId) { PullUpdateFuture pullRequest = new PullUpdateFuture(slave, txId); BlockingQueue <PullUpdateFuture> queue = GetOrCreateQueue(slave); // Add our request to the queue while (!queue.offer(pullRequest)) { Thread.yield(); } try { // Wait for request to finish pullRequest.get(); } catch (InterruptedException e) { Thread.interrupted(); // Clear interrupt flag throw new Exception(e); } catch (ExecutionException e) { if (e.InnerException is Exception) { throw ( Exception )e.InnerException; } else { throw new Exception(e.InnerException); } } }
private void AskSlaveToPullUpdates(PullUpdateFuture pullUpdateFuture) { Slave slave = pullUpdateFuture.Slave; long lastTxId = pullUpdateFuture.TxId; using (Response <Void> ignored = slave.PullUpdates(lastTxId)) { // Slave will come back to me(master) and pull updates } }
public void run() { try { while (true) { // Poll queue and call pullUpdate currentPulls.clear(); currentPulls.add(_finalQueue.take()); _finalQueue.drainTo(currentPulls); try { PullUpdateFuture pullUpdateFuture = currentPulls.get(0); outerInstance.askSlaveToPullUpdates(pullUpdateFuture); // Notify the futures foreach (PullUpdateFuture currentPull in currentPulls) { currentPull.Done(); } } catch (Exception e) { // Notify the futures foreach (PullUpdateFuture currentPull in currentPulls) { currentPull.Exception = e; } } } } catch (InterruptedException) { // Quit } }