protected override void GetExecuteRoute(HttpContext req) { try { var er = req.PostData <ExecuteRequest>(); if (er == null) { WriteError(req, Resources.WebErrorInvalidPostData); return; } var aCheck = Configuration.GetConsoleAction(er.Action); if (aCheck == null || !ExecuteActionFilter.Check(er.Action)) { WriteError(req, Resources.WebErrorActionUnavailable); return; } if (!File.Exists($"corpora/{er.CorpusId}.cec6")) { WriteError(req, Resources.WebErrorCorpusUnavailable); return; } var corpus = CorpusAdapterWriteDirect.Create($"corpora/{er.CorpusId}.cec6"); if (corpus == null) { WriteError(req, Resources.WebErrorCorpusUnavailable); return; } var selection = corpus.ToSelection(); var a = new ClusterAction(); var args = new List <string> { "XSGUID::TEXT", er.Action }; if (er.Arguments != null && er.Arguments.Length > 0) { args.AddRange(er.Arguments); } string response; using (var ms = new MemoryStream()) { var writer = Writer.Clone(ms); a.Execute(selection, args.ToArray(), writer); writer.Destroy(false); ms.Seek(0, SeekOrigin.Begin); response = Encoding.UTF8.GetString(ms.ToArray()); } req.Response.Send(response, Mime); } catch (Exception ex) { WriteError(req, ex.Message); } }
private void ExecuteAction(ClusterAction action, long termPosition) { if (isRecovering) { return; } long logPosition = termBaseLogPosition + termPosition; switch (action) { case ClusterAction.SNAPSHOT: OnTakeSnapshot(termPosition); serviceControlPublisher.AckAction(logPosition, leadershipTermId, serviceId, action); break; case ClusterAction.SHUTDOWN: OnTakeSnapshot(termPosition); serviceControlPublisher.AckAction(logPosition, leadershipTermId, serviceId, action); ctx.TerminationHook().Invoke(); break; case ClusterAction.ABORT: serviceControlPublisher.AckAction(logPosition, leadershipTermId, serviceId, action); ctx.TerminationHook().Invoke(); break; } }
private ClusterTestScriptDSL AddAction(ClusterAction action, long time) { action.time = Now + time; Actions.AddLast(action); Now += time; return(this); }
/// <summary> /// Managing timeouts is trickier than putting all of them in a long list, like regular message delivery. /// Timeouts are ordered and can be cancelled, so they need special treatment. Hence a separate method for /// managing timeouts triggering. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.helpers.collection.Pair<ClusterAction, ClusterState> performNextTimeoutFrom(ClusterInstance instance) throws Exception private Pair <ClusterAction, ClusterState> PerformNextTimeoutFrom(ClusterInstance instance) { ClusterState newState = Snapshot(); ClusterAction clusterAction = newState.Instance(instance.Uri().toASCIIString()).popTimeout(); clusterAction.Perform(newState); return(Pair.of(clusterAction, newState)); }
/// <summary> /// Clone the state and perform the action with the provided index. Returns the new state and the action. </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ClusterState performAction(ClusterAction action) throws Exception internal virtual ClusterState PerformAction(ClusterAction action) { ClusterState newState = Snapshot(); // Remove the action from the list of things that can happen in the snapshot newState._pendingActions.remove(action); // Perform the action on the cloned state IEnumerable <ClusterAction> newActions = action.Perform(newState); // Include any outcome actions into the new state snapshot newState._pendingActions.addAll(Iterables.asCollection(newActions)); return(newState); }
private void ExecuteAction(ClusterAction action, long position, long leadershipTermId) { if (isRecovering) { return; } switch (action) { case ClusterAction.SNAPSHOT: _consensusModuleProxy.Ack(position, ackId++, OnTakeSnapshot(position, leadershipTermId), serviceId); break; case ClusterAction.SHUTDOWN: _consensusModuleProxy.Ack(position, ackId++, OnTakeSnapshot(position, leadershipTermId), serviceId); ctx.TerminationHook().Invoke(); break; case ClusterAction.ABORT: _consensusModuleProxy.Ack(position, ackId++, serviceId); ctx.TerminationHook().Invoke(); break; } }
internal void OnServiceAction(long termPosition, long timestampMs, ClusterAction action) { this.timestampMs = timestampMs; ExecuteAction(action, termPosition); }
public void OnServiceAck(long logPosition, long leadershipTermId, int serviceId, ClusterAction action) { // Not Implemented }
public ClusterActionAckEncoder Action(ClusterAction value) { _buffer.PutInt(_offset + 20, (int)value, ByteOrder.LittleEndian); return(this); }
public void AckAction(long logPosition, long leadershipTermId, int serviceId, ClusterAction action) { int length = MessageHeaderEncoder.ENCODED_LENGTH + ClusterActionAckEncoder.BLOCK_LENGTH; int attempts = SEND_ATTEMPTS; do { long result = _publication.TryClaim(length, _bufferClaim); if (result > 0) { _clusterActionAckEncoder .WrapAndApplyHeader(_bufferClaim.Buffer, _bufferClaim.Offset, _messageHeaderEncoder) .LogPosition(logPosition) .LeadershipTermId(leadershipTermId) .ServiceId(serviceId) .Action(action); _bufferClaim.Commit(); return; } CheckResult(result); } while (--attempts > 0); throw new InvalidOperationException("failed to send ACK"); }
internal void OnServiceAction(long logPosition, long leadershipTermId, long timestampMs, ClusterAction action) { clusterTimeMs = timestampMs; ExecuteAction(action, logPosition, leadershipTermId); }