Fixed load time issue with ServerConfiguration.
This commit is contained in:
parent
f931bd26e6
commit
264df5af79
@ -23,7 +23,7 @@ public class ServerConfiguration extends MiniPlugin
|
||||
|
||||
Region region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
|
||||
for (ServerGroup serverGroup : ServerManager.getServerRepository(region).getServerGroups())
|
||||
for (ServerGroup serverGroup : ServerManager.getServerRepository(region).getServerGroups(false))
|
||||
{
|
||||
if (serverGroup.getName().equalsIgnoreCase(plugin.getConfig().getString("serverstatus.group")))
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ServerData,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ServerData,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ServerData,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Hub,Arcade,StaffServer,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Arcade,Hub,StaffServer,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Arcade,Hub,StaffServer,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${resource}"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
|
@ -241,7 +241,6 @@ public class RedisServerRepository implements ServerRepository
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
@ -261,21 +260,31 @@ public class RedisServerRepository implements ServerRepository
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ServerGroup> getServerGroups()
|
||||
public Collection<ServerGroup> getServerGroups(boolean fetch)
|
||||
{
|
||||
Collection<ServerGroup> servers = new HashSet<ServerGroup>();
|
||||
Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
String key = "servergroups";
|
||||
Set<String> names = jedis.smembers(key);
|
||||
|
||||
for (String groupName : names)
|
||||
Set<Response<Map<String, String>>> serverDatas = new HashSet<Response<Map<String, String>>>();
|
||||
|
||||
Pipeline pipeline = jedis.pipelined();
|
||||
|
||||
for (String serverName : names)
|
||||
{
|
||||
String dataKey = concatenate(key, groupName);
|
||||
Map<String, String> data = jedis.hgetAll(dataKey);
|
||||
servers.add(new ServerGroup(data, _region));
|
||||
String dataKey = concatenate(key, serverName);
|
||||
serverDatas.add(pipeline.hgetAll(dataKey));
|
||||
}
|
||||
|
||||
pipeline.sync();
|
||||
|
||||
for (Response<Map<String, String>> response : serverDatas)
|
||||
{
|
||||
Map<String, String> data = response.get();
|
||||
servers.add(new ServerGroup(data, _region, fetch));
|
||||
}
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
|
@ -137,7 +137,7 @@ public class ServerGroup
|
||||
* the internal state of this ServerGroup.
|
||||
* @param region - the region from which to fetch active {@link MinecraftServer}s.
|
||||
*/
|
||||
public ServerGroup(Map<String, String> data, Region region)
|
||||
public ServerGroup(Map<String, String> data, Region region, boolean fetch)
|
||||
{
|
||||
_name = data.get("name");
|
||||
_prefix = data.get("prefix");
|
||||
@ -176,7 +176,8 @@ public class ServerGroup
|
||||
_whitelist = Boolean.valueOf(data.get("whitelist"));
|
||||
_resourcePack = data.get("resourcePack");
|
||||
|
||||
fetchServers(region);
|
||||
if (fetch)
|
||||
fetchServers(region);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ public interface ServerRepository
|
||||
* @return a newly instanced snapshot {@link Collection} of all the
|
||||
* currently active {@link ServerGroup}s in the repository.
|
||||
*/
|
||||
public Collection<ServerGroup> getServerGroups();
|
||||
public Collection<ServerGroup> getServerGroups(boolean fetch);
|
||||
|
||||
public Collection<MinecraftServer> getDeadServers();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class ServerMonitor
|
||||
|
||||
while (true)
|
||||
{
|
||||
Collection<ServerGroup> serverGroups = _repository.getServerGroups();
|
||||
Collection<ServerGroup> serverGroups = _repository.getServerGroups(true);
|
||||
Collection<MinecraftServer> serverStatuses = _repository.getServerStatuses();
|
||||
|
||||
for (MinecraftServer deadServer : _repository.getDeadServers())
|
||||
|
Loading…
Reference in New Issue
Block a user