Skip to content

Commit

Permalink
change history nodes storage from list to set
Browse files Browse the repository at this point in the history
  • Loading branch information
息羽 committed Nov 17, 2015
1 parent e843fa1 commit 854783c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/main/java/darks/grid/manager/GridStorageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import java.io.File;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import darks.grid.config.GridConfiguration;
import darks.grid.utils.FileUtils;
Expand Down Expand Up @@ -63,12 +66,12 @@ public synchronized void cacheHistoryNodes(InetSocketAddress address)
FileUtils.appendLine(historyNodesFile, addr);
}

public synchronized List<InetSocketAddress> getCacheHistoryNodes()
public synchronized Collection<InetSocketAddress> getCacheHistoryNodes()
{
if (historyNodesFile.exists())
{
List<String> addresses = FileUtils.readLineToList(historyNodesFile);
List<InetSocketAddress> result = new ArrayList<>(addresses.size());
Set<InetSocketAddress> result = new HashSet<>(addresses.size());
for (String addr : addresses)
{
String[] datas = addr.split(":");
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/darks/grid/network/discovery/TCPPING.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.slf4j.Logger;
Expand Down Expand Up @@ -60,7 +58,7 @@ public void findNodes()
tryAddrs.add(address);
}
}
List<InetSocketAddress> cacheAddrs = GridRuntime.storage().getCacheHistoryNodes();
Collection<InetSocketAddress> cacheAddrs = GridRuntime.storage().getCacheHistoryNodes();
if (cacheAddrs != null)
{
for (InetSocketAddress address : cacheAddrs)
Expand Down

0 comments on commit 854783c

Please sign in to comment.