Created
March 28, 2018 15:56
-
-
Save csjx/8990e8e8f6fd74756857f6c166f60dfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package org.dataone.tests; | |
import com.hazelcast.client.ClientConfig; | |
import com.hazelcast.client.HazelcastClient; | |
import com.hazelcast.config.GroupConfig; | |
import com.hazelcast.core.IQueue; | |
/** | |
* Polls the index queue in a local Metacat, or | |
* a remote Metacat via an SSH tunnel | |
* | |
* @author cjones | |
* | |
*/ | |
public class MetacatIndexPoller { | |
private static String groupName = ""; | |
private static String groupPassword = ""; | |
private static String address = "127.0.0.1:5701"; | |
// Queue for CN sync tasks | |
private static IQueue<Object> hzIndexQueue = null; | |
private static HazelcastClient hzClient = null; | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
ClientConfig config = new ClientConfig(); | |
config.addAddress(address); | |
GroupConfig groupConfig = new GroupConfig(); | |
groupConfig.setName(groupName); | |
groupConfig.setPassword(groupPassword); | |
config.setGroupConfig(groupConfig); | |
try { | |
hzClient = HazelcastClient.newHazelcastClient(config); | |
int sz = hzClient.getCluster().getMembers().size(); | |
System.out.println("Cluster size: " + sz); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
int count = 200000; | |
// Poll the queue size for <count> seconds | |
for (int i = 0; i < count; i++) { | |
hzIndexQueue = hzClient.getQueue("hzIndexQueue"); | |
int size = hzIndexQueue.size(); | |
System.out.println(size); | |
try { | |
Thread.sleep(5000); | |
} catch (InterruptedException e) { | |
Thread.currentThread().interrupt(); | |
} | |
} | |
System.exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment