Skip to content

Commit

Permalink
Simplify and generalize
Browse files Browse the repository at this point in the history
  • Loading branch information
mausch committed Mar 3, 2014
1 parent 91fdbfd commit 61e4ffd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
23 changes: 5 additions & 18 deletions SolrNet/Commands/Replication/FetchIndexCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#endregion

using System;
using System.Collections.Generic;
using System.Collections.Generic;

namespace SolrNet.Commands.Replication
{
Expand All @@ -26,33 +26,20 @@ namespace SolrNet.Commands.Replication
/// </summary>
public class FetchIndexCommand : ReplicationCommand
{
/// <summary>
/// Forces the specified slave to fetch a copy of the index from its master. If you like, you
/// can pass an extra attribute such as masterUrl or compression (or any other parameter which
/// is specified in the <lst name="slave" /> tag) to do a one time replication from a master.
/// This obviates the need for hard-coding the master in the slave.
/// </summary>
public FetchIndexCommand()
{
AddParameter("command", "fetchindex");
}

/// <summary>
/// Forces the specified slave to fetch a copy of the index from its master. If you like, you
/// can pass an extra attribute such as masterUrl or compression (or any other parameter which
/// is specified in the <lst name="slave" /> tag) to do a one time replication from a master.
/// This obviates the need for hard-coding the master in the slave.
/// </summary>
/// <param name="parameters">Optional parameters</param>
public FetchIndexCommand(Dictionary<string, string> parameters)
public FetchIndexCommand(IEnumerable<KeyValuePair<string, string>> parameters)
{
if (parameters == null || parameters.Count == 0)
throw new ArgumentException("Parameters must be specified.", "parameters");

AddParameter("command", "fetchindex");

foreach (string key in parameters.Keys)
AddParameter(key, parameters[key]);
if (parameters != null)
foreach (var kv in parameters)
AddParameter(kv.Key, kv.Value);
}
}
}
2 changes: 1 addition & 1 deletion SolrNet/ISolrCoreReplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface ISolrCoreReplication
/// This obviates the need for hard-coding the master in the slave.
/// </summary>
/// <param name="parameters">Optional parameters</param>
ReplicationStatusResponse FetchIndex(Dictionary<string, string> parameters);
ReplicationStatusResponse FetchIndex(IEnumerable<KeyValuePair<string, string>> parameters);

/// <summary>
/// Aborts copying an index from a master to the specified slave.
Expand Down
4 changes: 2 additions & 2 deletions SolrNet/Impl/SolrCoreReplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public ReplicationStatusResponse DisablePoll()
/// </summary>
public ReplicationStatusResponse FetchIndex()
{
return SendAndParseStatus(new FetchIndexCommand());
return FetchIndex(null);
}

/// <summary>
Expand All @@ -100,7 +100,7 @@ public ReplicationStatusResponse FetchIndex()
/// This obviates the need for hard-coding the master in the slave.
/// </summary>
/// <param name="parameters">Optional parameters</param>
public ReplicationStatusResponse FetchIndex(Dictionary<string, string> parameters)
public ReplicationStatusResponse FetchIndex(IEnumerable<KeyValuePair<string, string>> parameters)
{
return SendAndParseStatus(new FetchIndexCommand(parameters));
}
Expand Down

0 comments on commit 61e4ffd

Please sign in to comment.