Java 如何从伏地魔商店一次获得所有键值对? intmaxthreads=300; ClientConfig ClientConfig=new ClientConfig(); setMaxThreads(maxThreads); setMaxConnectionsPerNode(maxThreads); clientConfig.setConnectionTimeout(500,时间单位为毫秒); setBootstrapUrls(env.getVoldemortAddress()); StoreClientFactory=新的SocketStoreClientFactory(clientConfig); StoreClient=factory.getStoreClient(env.getPrefixStoreName());
现在如何一次从存储中获取所有键值对?您必须使用Java 如何从伏地魔商店一次获得所有键值对? intmaxthreads=300; ClientConfig ClientConfig=new ClientConfig(); setMaxThreads(maxThreads); setMaxConnectionsPerNode(maxThreads); clientConfig.setConnectionTimeout(500,时间单位为毫秒); setBootstrapUrls(env.getVoldemortAddress()); StoreClientFactory=新的SocketStoreClientFactory(clientConfig); StoreClient=factory.getStoreClient(env.getPrefixStoreName());,java,voldemort,Java,Voldemort,现在如何一次从存储中获取所有键值对?您必须使用AdminClient获取所有键。此类用于有用且经常需要的管理功能,但在应用程序级别应尽量少用(如果有的话) publicstaticvoidmain(字符串[]args){ 字符串bootStrapUrl=”tcp://localhost:6666"; 字符串storeName=“test”; int最大线程数=300; ClientConfig ClientConfig=new ClientConfig(); setMaxThreads(maxT
AdminClient
获取所有键。此类用于有用且经常需要的管理功能,但在应用程序级别应尽量少用(如果有的话)
publicstaticvoidmain(字符串[]args){
字符串bootStrapUrl=”tcp://localhost:6666";
字符串storeName=“test”;
int最大线程数=300;
ClientConfig ClientConfig=new ClientConfig();
setMaxThreads(maxThreads);
setMaxConnectionsPerNode(maxThreads);
clientConfig.setConnectionTimeout(500,时间单位为毫秒);
setBootstrapUrls(bootStrapUrl);
StoreClientFactory=新的SocketStoreClientFactory(clientConfig);
StoreClient=factory.getStoreClient(storeName);
int nodeId=0;
List partitionList=new ArrayList();
分区列表。添加(0);
分区列表。添加(1);
AdminClient AdminClient=newadminclient(bootStrapUrl,newadminclientconfig());
迭代器迭代器=adminClient.fetchKeys(nodeId、storeName、partitionList、null);
字符串键=null;
字符串值=null;
while(iterator.hasNext()){
key=新字符串(iterator.next().get());
value=client.getValue(key);
System.out.println(“键值对:“+Key+”:“+Value”);
}
}
int maxThreads = 300;
ClientConfig clientConfig = new ClientConfig();
clientConfig.setMaxThreads(maxThreads);
clientConfig.setMaxConnectionsPerNode(maxThreads);
clientConfig.setConnectionTimeout(500, TimeUnit.MILLISECONDS);
clientConfig.setBootstrapUrls(env.getVoldemortAddress());
StoreClientFactory factory = new SocketStoreClientFactory(clientConfig);
StoreClient<String, String> client = factory.getStoreClient(env.getPrefixStoreName());
public static void main(String [] args) {
String bootStrapUrl = "tcp://localhost:6666";
String storeName = "test";
int maxThreads = 300;
ClientConfig clientConfig = new ClientConfig();
clientConfig.setMaxThreads(maxThreads);
clientConfig.setMaxConnectionsPerNode(maxThreads);
clientConfig.setConnectionTimeout(500, TimeUnit.MILLISECONDS);
clientConfig.setBootstrapUrls(bootStrapUrl);
StoreClientFactory factory = new SocketStoreClientFactory(clientConfig);
StoreClient<String, String> client = factory.getStoreClient(storeName);
int nodeId = 0;
List<Integer> partitionList = new ArrayList<Integer>();
partitionList.add(0);
partitionList.add(1);
AdminClient adminClient = new AdminClient(bootStrapUrl, new AdminClientConfig());
Iterator<ByteArray> iterator = adminClient.fetchKeys(nodeId, storeName, partitionList, null);
String key = null;
String value = null;
while (iterator.hasNext()) {
key = new String(iterator.next().get());
value = client.getValue(key);
System.out.println("Key-Value-Pair::" + key + ":" + value);
}
}