private static void UpdateClientInternal(IReplicationResponse update) { //for (int i = 0; i < 10; i++) //{ try { ReplicatedSessionSubscriberDetails user = null; try { user = GetDetails(update.ClientKey); } catch (Exception inex) { SystemLogger.WriteOnConsoleAsync(true, string.Format("Error UpdateClientInternal {0} , Error: {1}, Retrying to send, you will get the same error if retrial failed", update.ClientKey.ToString(), inex.Message), ConsoleColor.Red, ConsoleColor.Black, true); user = GetDetails(new Guid(update.ClientKey.ToString())); } user.SessionRemoteQueue.Send(update); //break; //SystemLogger.WriteOnConsole(true, string.Format("Message sent of type ({0}) to client {1}", update.GetType().ToString(), update.ClientKey), ConsoleColor.Cyan, ConsoleColor.Black, false); } catch (Exception ex) { Counters.IncrementCounter(CountersConstants.ExceptionMessages); SystemLogger.WriteOnConsoleAsync(true, string.Format("Error UpdateClientInternal: {0}", ex.Message), ConsoleColor.Red, ConsoleColor.Black, true); } // } }
// LUCENENET specific - copy method not used /// <summary> /// Executes the replication task. /// </summary> /// <exception cref="InvalidOperationException">required parameters are missing</exception> public virtual void Perform(IReplicationRequest request, IReplicationResponse response) { string[] pathElements = GetPathElements(request); if (pathElements.Length != 2) { throw new InvalidOperationException("invalid path, must contain shard ID and action, e.g. */s1/update"); } if (!Enum.TryParse(pathElements[ACTION_IDX], true, out ReplicationAction action)) { throw new InvalidOperationException("Unsupported action provided: " + pathElements[ACTION_IDX]); } if (!replicators.TryGetValue(pathElements[SHARD_IDX], out IReplicator replicator)) { throw new InvalidOperationException("unrecognized shard ID " + pathElements[SHARD_IDX]); } // SOLR-8933 Don't close this stream. try { switch (action) { case ReplicationAction.OBTAIN: string sessionId = ExtractRequestParam(request, REPLICATE_SESSION_ID_PARAM); string fileName = ExtractRequestParam(request, REPLICATE_FILENAME_PARAM); string source = ExtractRequestParam(request, REPLICATE_SOURCE_PARAM); using (Stream stream = replicator.ObtainFile(sessionId, source, fileName)) stream.CopyTo(response.Body); break; case ReplicationAction.RELEASE: replicator.Release(ExtractRequestParam(request, REPLICATE_SESSION_ID_PARAM)); break; case ReplicationAction.UPDATE: string currentVersion = request.QueryParam(REPLICATE_VERSION_PARAM); SessionToken token = replicator.CheckForUpdate(currentVersion); if (token == null) { response.Body.Write(new byte[] { 0 }, 0, 1); // marker for null token } else { response.Body.Write(new byte[] { 1 }, 0, 1); token.Serialize(new DataOutputStream(response.Body)); } break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception e) { response.StatusCode = 500; try { TextWriter writer = new StreamWriter(response.Body); JsonSerializer serializer = JsonSerializer.Create(JSON_SERIALIZER_SETTINGS); serializer.Serialize(writer, e, e.GetType()); } catch (Exception exception) { throw new IOException("Could not serialize", exception); } } finally { response.Flush(); } }