You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bi...@apache.org on 2011/12/14 21:47:48 UTC
svn commit: r1214459 - in
/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client:
admin/ impl/ mock/
Author: billie
Date: Wed Dec 14 20:47:47 2011
New Revision: 1214459
URL: http://svn.apache.org/viewvc?rev=1214459&view=rev
Log:
ACCUMULO-216 merged to trunk
Added:
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
- copied unchanged from r1214447, incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
- copied unchanged from r1214447, incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
Modified:
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java?rev=1214459&r1=1214458&r2=1214459&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java Wed Dec 14 20:47:47 2011
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -16,49 +16,16 @@
*/
package org.apache.accumulo.core.client.admin;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.ClientExec;
-import org.apache.accumulo.core.client.impl.ClientExecReturn;
-import org.apache.accumulo.core.client.impl.MasterClient;
-import org.apache.accumulo.core.client.impl.ServerClient;
-import org.apache.accumulo.core.client.impl.thrift.ClientService;
-import org.apache.accumulo.core.client.impl.thrift.ConfigurationType;
-import org.apache.accumulo.core.master.thrift.MasterClientService;
-import org.apache.accumulo.core.security.thrift.AuthInfo;
-import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
-import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface;
-import org.apache.accumulo.core.util.ArgumentChecker;
-import org.apache.accumulo.core.util.ThriftUtil;
-import org.apache.accumulo.core.zookeeper.ZooCache;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
/**
- * Provides a class for administering the accumulo instance
+ *
*/
-public class InstanceOperations {
- private Instance instance;
- private AuthInfo credentials;
-
- /**
- * @param instance
- * the connection information for this instance
- * @param credentials
- * the username/password for this connection
- */
- public InstanceOperations(Instance instance, AuthInfo credentials) {
- ArgumentChecker.notNull(instance, credentials);
- this.instance = instance;
- this.credentials = credentials;
- }
+public interface InstanceOperations {
/**
* Sets an instance property in zookeeper. Tablet servers will pull this setting and override the equivalent setting in accumulo-site.xml
@@ -72,15 +39,7 @@ public class InstanceOperations {
* @throws AccumuloSecurityException
* if the user does not have permission
*/
- public void setProperty(final String property, final String value) throws AccumuloException, AccumuloSecurityException {
- ArgumentChecker.notNull(property, value);
- MasterClient.execute(instance, new ClientExec<MasterClientService.Iface>() {
- @Override
- public void execute(MasterClientService.Iface client) throws Exception {
- client.setSystemProperty(null, credentials, property, value);
- }
- });
- }
+ public void setProperty(final String property, final String value) throws AccumuloException, AccumuloSecurityException;
/**
* Removes a instance property from zookeeper
@@ -94,33 +53,11 @@ public class InstanceOperations {
* @throws AccumuloSecurityException
* if the user does not have permission
*/
- public void removeProperty(final String property) throws AccumuloException, AccumuloSecurityException {
- ArgumentChecker.notNull(property);
- MasterClient.execute(instance, new ClientExec<MasterClientService.Iface>() {
- @Override
- public void execute(MasterClientService.Iface client) throws Exception {
- client.removeSystemProperty(null, credentials, property);
- }
- });
- }
-
- public Map<String,String> getSystemConfiguration() throws AccumuloException, AccumuloSecurityException {
- return ServerClient.execute(instance, new ClientExecReturn<Map<String,String>,ClientService.Iface>() {
- @Override
- public Map<String,String> execute(ClientService.Iface client) throws Exception {
- return client.getConfiguration(ConfigurationType.CURRENT);
- }
- });
- }
-
- public Map<String,String> getSiteConfiguration() throws AccumuloException, AccumuloSecurityException {
- return ServerClient.execute(instance, new ClientExecReturn<Map<String,String>,ClientService.Iface>() {
- @Override
- public Map<String,String> execute(ClientService.Iface client) throws Exception {
- return client.getConfiguration(ConfigurationType.SITE);
- }
- });
- }
+ public void removeProperty(final String property) throws AccumuloException, AccumuloSecurityException;
+
+ public Map<String,String> getSystemConfiguration() throws AccumuloException, AccumuloSecurityException;
+
+ public Map<String,String> getSiteConfiguration() throws AccumuloException, AccumuloSecurityException;
/**
* List the currently active tablet servers participating in the accumulo instance
@@ -128,23 +65,7 @@ public class InstanceOperations {
* @return
*/
- public List<String> getTabletServers() {
- ZooCache cache = ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
- String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
- List<String> results = new ArrayList<String>();
- for (String candidate : cache.getChildren(path)) {
- List<String> children = cache.getChildren(path + "/" + candidate);
- if (children != null && children.size() > 0) {
- List<String> copy = new ArrayList<String>(children);
- Collections.sort(copy);
- byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
- if (data != null && !"master".equals(new String(data))) {
- results.add(candidate);
- }
- }
- }
- return results;
- }
+ public List<String> getTabletServers();
/**
* List the active scans on tablet server. The tablet server address should be of the form <ip address>:<port>
@@ -155,24 +76,7 @@ public class InstanceOperations {
* @throws AccumuloSecurityException
*/
- public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException {
- List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan> tas = ThriftUtil.execute(tserver, instance.getConfiguration(),
- new ClientExecReturn<List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan>,TabletClientService.Iface>() {
- @Override
- public List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan> execute(Iface client) throws Exception {
- return client.getActiveScans(null, credentials);
- }
- });
- List<ActiveScan> as = new ArrayList<ActiveScan>();
- for (org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan : tas) {
- try {
- as.add(new ActiveScan(instance, activeScan));
- } catch (TableNotFoundException e) {
- throw new AccumuloException(e);
- }
- }
- return as;
- }
+ public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException;
/**
* Test to see if the instance can load the given class as the given type.
@@ -182,12 +86,6 @@ public class InstanceOperations {
* @return
* @throws AccumuloException
*/
- public boolean testClassLoad(final String className, final String asTypeName) throws AccumuloException, AccumuloSecurityException {
- return ServerClient.execute(instance, new ClientExecReturn<Boolean,ClientService.Iface>() {
- @Override
- public Boolean execute(ClientService.Iface client) throws Exception {
- return client.checkClass(null, className, asTypeName);
- }
- });
- }
+ public boolean testClassLoad(final String className, final String asTypeName) throws AccumuloException, AccumuloSecurityException;
+
}
Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java?rev=1214459&r1=1214458&r2=1214459&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java Wed Dec 14 20:47:47 2011
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.client.S
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.TableOfflineException;
import org.apache.accumulo.core.client.admin.InstanceOperations;
+import org.apache.accumulo.core.client.admin.InstanceOperationsImpl;
import org.apache.accumulo.core.client.admin.SecurityOperations;
import org.apache.accumulo.core.client.admin.SecurityOperationsImpl;
import org.apache.accumulo.core.client.admin.TableOperations;
@@ -165,7 +166,7 @@ public class ConnectorImpl extends Conne
@Override
public synchronized InstanceOperations instanceOperations() {
if (instanceops == null)
- instanceops = new InstanceOperations(instance, credentials);
+ instanceops = new InstanceOperationsImpl(instance, credentials);
return instanceops;
}
Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java?rev=1214459&r1=1214458&r2=1214459&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java Wed Dec 14 20:47:47 2011
@@ -46,6 +46,10 @@ public class MockAccumulo {
systemProperties.put(key, value);
}
+ String removeProperty(String key) {
+ return systemProperties.remove(key);
+ }
+
void createTable(String user, String table) {
createTable(user, table, true, TimeType.MILLIS);
}
Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java?rev=1214459&r1=1214458&r2=1214459&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java Wed Dec 14 20:47:47 2011
@@ -96,7 +96,7 @@ public class MockConnector extends Conne
@Override
public InstanceOperations instanceOperations() {
- return null;
+ return new MockInstanceOperations(acu);
}
}