public ClientContext(Properties clientProperties) { this(ClientInfo.from(clientProperties)); }
private ServerContext(SiteConfiguration siteConfig, ClientInfo info) { this(new ServerInfo(siteConfig, info.getInstanceName(), info.getZooKeepers(), info.getZooKeepersSessionTimeOut())); }
/** * Retrieve the credentials used to construct this context */ public synchronized Credentials getCredentials() { ensureOpen(); if (creds == null) { creds = new Credentials(info.getPrincipal(), info.getAuthenticationToken()); } return creds; }
public String getDefaultPrompt() { Objects.nonNull(accumuloClient); ClientInfo info = ClientInfo.from(accumuloClient.properties()); return accumuloClient.whoami() + "@" + info.getInstanceName() + (getTableName().isEmpty() ? "" : " ") + getTableName() + "> "; }
public ClientContext(SingletonReservation reservation, ClientInfo info, AccumuloConfiguration serverConf) { this.info = info; this.hadoopConf = info.getHadoopConf(); zooCache = new ZooCacheFactory().getZooCache(info.getZooKeepers(), info.getZooKeepersSessionTimeOut()); this.serverConf = serverConf; timeoutSupplier = memoizeWithExpiration( () -> getConfiguration().getTimeInMillis(Property.GENERAL_RPC_TIMEOUT)); sslSupplier = memoizeWithExpiration(() -> SslConnectionParams.forClient(getConfiguration())); saslSupplier = memoizeWithExpiration( () -> SaslConnectionParams.from(getConfiguration(), getCredentials().getToken())); this.singletonReservation = Objects.requireNonNull(reservation); this.tableops = new TableOperationsImpl(this); this.namespaceops = new NamespaceOperationsImpl(this, tableops); }
/** * Returns the instance name given at system initialization time. * * @return current instance name */ public String getInstanceName() { ensureOpen(); return info.getInstanceName(); }
/** * Returns the zookeeper connection timeout. * * @return the configured timeout to connect to zookeeper */ public int getZooKeepersSessionTimeOut() { ensureOpen(); return info.getZooKeepersSessionTimeOut(); }
/** * Returns a comma-separated list of zookeeper servers the instance is using. * * @return the zookeeper servers this instance is using in "hostname:port" form */ public String getZooKeepers() { ensureOpen(); return info.getZooKeepers(); }
public void printInfo() throws IOException { ClientInfo info = ClientInfo.from(accumuloClient.properties()); reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: " + info.getInstanceName() + "\n" + "- instance id: " + accumuloClient.getInstanceID() + "\n" + "- \n" + "- type 'help' for a list of available commands\n" + "- \n"); reader.flush(); }
/** * Returns a unique string that identifies this instance of accumulo. * * @return a UUID */ @Override public String getInstanceID() { ensureOpen(); final String instanceName = info.getInstanceName(); if (instanceId == null) { // want the instance id to be stable for the life of this instance object, // so only get it once String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + instanceName; byte[] iidb = zooCache.get(instanceNamePath); if (iidb == null) { throw new RuntimeException( "Instance name " + instanceName + " does not exist in zookeeper. " + "Run \"accumulo org.apache.accumulo.server.util.ListInstances\" to see a list."); } instanceId = new String(iidb, UTF_8); } if (zooCache.get(Constants.ZROOT + "/" + instanceId) == null) { if (instanceName == null) throw new RuntimeException("Instance id " + instanceId + " does not exist in zookeeper"); throw new RuntimeException("Instance id " + instanceId + " pointed to by the name " + instanceName + " does not exist in zookeeper"); } return instanceId; }
public ServerContext(SiteConfiguration siteConfig, Properties clientProps) { this(siteConfig, ClientInfo.from(clientProps)); }
protected ClientContext getContextForPeer(AccumuloConfiguration localConf, ReplicationTarget target, String principal, AuthenticationToken token) { requireNonNull(localConf); requireNonNull(target); requireNonNull(principal); requireNonNull(token); Properties properties = new Properties(); properties.setProperty(ClientProperty.INSTANCE_NAME.getKey(), instanceName); properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), zookeepers); properties.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), principal); ClientProperty.setAuthenticationToken(properties, token); return new ClientContext(ClientInfo.from(properties, token), localConf); }