public static SystemCredentials get(String instanceID, SiteConfiguration siteConfig) { String principal = SYSTEM_PRINCIPAL; if (siteConfig.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) { // Use the server's kerberos principal as the Accumulo principal. We could also unwrap the // principal server-side, but the principal for SystemCredentials // isn't actually used anywhere, so it really doesn't matter. We can't include the kerberos // principal in the SystemToken as it would break equality when // different Accumulo servers are using different kerberos principals are their accumulo // principal principal = SecurityUtil .getServerPrincipal(siteConfig.get(Property.GENERAL_KERBEROS_PRINCIPAL)); } return new SystemCredentials(instanceID, principal, SystemToken.get(instanceID, siteConfig)); }
/** * Create warning message related to initial password, if appropriate. * * ACCUMULO-2907 Remove unnecessary security warning from console message unless its actually * appropriate. The warning message should only be displayed when the value of * <code>instance.security.authenticator</code> differs between the SiteConfiguration and the * DefaultConfiguration values. * * @return String containing warning portion of console message. */ private String getInitialPasswordWarning(SiteConfiguration siteConfig) { String optionalWarning; Property authenticatorProperty = Property.INSTANCE_SECURITY_AUTHENTICATOR; if (siteConfig.get(authenticatorProperty).equals(authenticatorProperty.getDefaultValue())) optionalWarning = ": "; else optionalWarning = " (this may not be applicable for your security setup): "; return optionalWarning; }
ServerInfo(SiteConfiguration config) { SingletonManager.setMode(Mode.SERVER); siteConfig = config; hadoopConf = new Configuration(); try { volumeManager = VolumeManagerImpl.get(siteConfig, hadoopConf); } catch (IOException e) { throw new IllegalStateException(e); } Path instanceIdPath = ServerUtil.getAccumuloInstanceIdPath(volumeManager); instanceID = ZooUtil.getInstanceIDFromHdfs(instanceIdPath, config, hadoopConf); zooKeepers = config.get(Property.INSTANCE_ZK_HOST); zooKeepersSessionTimeOut = (int) config.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT); zooCache = new ZooCacheFactory().getZooCache(zooKeepers, zooKeepersSessionTimeOut); instanceName = InstanceOperationsImpl.lookupInstanceName(zooCache, UUID.fromString(instanceID)); }
private static String getDefaultKeyPassword() { return SiteConfiguration.getInstance().get(Property.INSTANCE_SECRET); }
public static void main(String[] args) { opts.parseArgs(ListInstances.class.getName(), args); if (opts.keepers == null) { opts.keepers = SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST); } String keepers = opts.keepers; boolean printAll = opts.printAll; boolean printErrors = opts.printErrors; listInstances(keepers, printAll, printErrors); }
static void printInitializeFailureMessages(SiteConfiguration sconf, Configuration hadoopConf) { @SuppressWarnings("deprecation") Property INSTANCE_DFS_DIR = Property.INSTANCE_DFS_DIR; @SuppressWarnings("deprecation") Property INSTANCE_DFS_URI = Property.INSTANCE_DFS_URI; String instanceDfsDir = sconf.get(INSTANCE_DFS_DIR); // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility log.error("FATAL It appears the directories {}", Arrays.asList(VolumeConfiguration.getVolumeUris(sconf, hadoopConf)) + " were previously initialized."); String instanceVolumes = sconf.get(Property.INSTANCE_VOLUMES); String instanceDfsUri = sconf.get(INSTANCE_DFS_URI); // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility if (!instanceVolumes.isEmpty()) { log.error("FATAL: Change the property {} to use different filesystems,", Property.INSTANCE_VOLUMES); } else if (!instanceDfsDir.isEmpty()) { log.error("FATAL: Change the property {} to use a different filesystem,", INSTANCE_DFS_URI); } else { log.error("FATAL: You are using the default URI for the filesystem. Set" + " the property {} to use a different filesystem,", Property.INSTANCE_VOLUMES); } log.error("FATAL: or change the property {} to use a different directory.", INSTANCE_DFS_DIR); log.error("FATAL: The current value of {} is |{}|", INSTANCE_DFS_URI, instanceDfsUri); log.error("FATAL: The current value of {} is |{}|", INSTANCE_DFS_DIR, instanceDfsDir); log.error("FATAL: The current value of {} is |{}|", Property.INSTANCE_VOLUMES, instanceVolumes); }
private String getRootUserName(SiteConfiguration siteConfig, Opts opts) throws IOException { final String keytab = siteConfig.get(Property.GENERAL_KERBEROS_KEYTAB); if (keytab.equals(Property.GENERAL_KERBEROS_KEYTAB.getDefaultValue()) || !siteConfig.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) { return DEFAULT_ROOT_USER; } ConsoleReader c = getConsoleReader(); c.println("Running against secured HDFS"); if (opts.rootUser != null) { return opts.rootUser; } do { String user = c.readLine("Principal (user) to grant administrative privileges to : "); if (user == null) { // should not happen System.exit(1); } if (!user.isEmpty()) { return user; } } while (true); }
static void printInitializeFailureMessages(SiteConfiguration sconf) { @SuppressWarnings("deprecation") Property INSTANCE_DFS_DIR = Property.INSTANCE_DFS_DIR; @SuppressWarnings("deprecation") Property INSTANCE_DFS_URI = Property.INSTANCE_DFS_URI; String instanceDfsDir = sconf.get(INSTANCE_DFS_DIR); // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility log.error("FATAL It appears the directories " + Arrays.asList(VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance())) + " were previously initialized."); String instanceVolumes = sconf.get(Property.INSTANCE_VOLUMES); String instanceDfsUri = sconf.get(INSTANCE_DFS_URI); // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility if (!instanceVolumes.isEmpty()) { log.error("FATAL: Change the property " + Property.INSTANCE_VOLUMES + " to use different filesystems,"); } else if (!instanceDfsDir.isEmpty()) { log.error( "FATAL: Change the property " + INSTANCE_DFS_URI + " to use a different filesystem,"); } else { log.error("FATAL: You are using the default URI for the filesystem. Set the property " + Property.INSTANCE_VOLUMES + " to use a different filesystem,"); } log.error( "FATAL: or change the property " + INSTANCE_DFS_DIR + " to use a different directory."); log.error("FATAL: The current value of " + INSTANCE_DFS_URI + " is |" + instanceDfsUri + "|"); log.error("FATAL: The current value of " + INSTANCE_DFS_DIR + " is |" + instanceDfsDir + "|"); log.error("FATAL: The current value of " + Property.INSTANCE_VOLUMES + " is |" + instanceVolumes + "|"); }
protected synchronized IZooReaderWriter getZooReaderWriter(ClientContext context, SiteConfiguration siteConfig, String secret) { if (secret == null) { secret = siteConfig.get(Property.INSTANCE_SECRET); } return new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(), SCHEME, (USER + ":" + secret).getBytes()); }
String path = siteConf.get(Property.TRACE_ZK_PATH); try { zapDirectory(zoo, path, opts);
/** * Get the ZooKeepers. Use the value passed in (if there was one), then fall back to the * ClientConf, finally trying the accumulo-site.xml. * * @param keepers * ZooKeepers passed to the shell * @param clientConfig * ClientConfiguration instance * @return The ZooKeepers to connect to */ static String getZooKeepers(String keepers, ClientConfiguration clientConfig) { if (null != keepers) { return keepers; } if (clientConfig.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) { return clientConfig.get(ClientProperty.INSTANCE_ZK_HOST); } return SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST); }
public static void main(String[] args) { opts.parseArgs(ListInstances.class.getName(), args); if (opts.keepers == null) { SiteConfiguration siteConfig = new SiteConfiguration(); opts.keepers = siteConfig.get(Property.INSTANCE_ZK_HOST); } String keepers = opts.keepers; boolean printAll = opts.printAll; boolean printErrors = opts.printErrors; listInstances(keepers, printAll, printErrors); }
EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class))) .andAnswer(new IAnswer<String>() { @Override
static boolean checkInit(Configuration conf, VolumeManager fs, SiteConfiguration sconf) throws IOException { @SuppressWarnings("deprecation") String fsUri = sconf.get(Property.INSTANCE_DFS_URI); if (fsUri.equals("")) fsUri = FileSystem.getDefaultUri(conf).toString(); log.info("Accumulo data dirs are " + Arrays.asList(VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance()))); log.info("Zookeeper server is " + sconf.get(Property.INSTANCE_ZK_HOST)); log.info("Checking if Zookeeper is available. If this hangs, then you need" + " to make sure zookeeper is running"); return false; if (sconf.get(Property.INSTANCE_SECRET).equals(Property.INSTANCE_SECRET.getDefaultValue())) { ConsoleReader c = getConsoleReader(); c.beep();
static boolean checkInit(Configuration conf, VolumeManager fs, SiteConfiguration sconf, Configuration hadoopConf) throws IOException { @SuppressWarnings("deprecation") String fsUri = sconf.get(Property.INSTANCE_DFS_URI); if (fsUri.equals("")) fsUri = FileSystem.getDefaultUri(conf).toString(); log.info("Accumulo data dirs are {}", Arrays.asList(VolumeConfiguration.getVolumeUris(sconf, hadoopConf))); log.info("Zookeeper server is {}", sconf.get(Property.INSTANCE_ZK_HOST)); log.info("Checking if Zookeeper is available. If this hangs, then you need" + " to make sure zookeeper is running"); return false; if (sconf.get(Property.INSTANCE_SECRET).equals(Property.INSTANCE_SECRET.getDefaultValue())) { ConsoleReader c = getConsoleReader(); c.beep();
public static String getBaseDir() { return ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_DFS_DIR); }
@Override public String getZooKeepers() { return ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST); }
String zookeepers[] = ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST).split(","); for (String keeper : zookeepers) { int clients = 0;
public static void main(String[] args) { opts.parseArgs(ListInstances.class.getName(), args); if (opts.keepers == null) { opts.keepers = ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST); } System.out.println("INFO : Using ZooKeepers " + opts.keepers); ZooReader rdr = new ZooReader(opts.keepers, ZOOKEEPER_TIMER_MILLIS); ZooCache cache = new ZooCache(opts.keepers, ZOOKEEPER_TIMER_MILLIS); TreeMap<String,UUID> instanceNames = getInstanceNames(rdr); System.out.println(); printHeader(); for (Entry<String,UUID> entry : instanceNames.entrySet()) { printInstanceInfo(cache, entry.getKey(), entry.getValue()); } TreeSet<UUID> instancedIds = getInstanceIDs(rdr); instancedIds.removeAll(instanceNames.values()); if (opts.printAll) { for (UUID uuid : instancedIds) { printInstanceInfo(cache, null, uuid); } } else if (instancedIds.size() > 0) { System.out.println(); System.out.println("INFO : " + instancedIds.size() + " unamed instances were not printed, run with --print-all to see all instances"); } else { System.out.println(); } if (!opts.printErrors && errors > 0) { System.err.println("WARN : There were " + errors + " errors, run with --print-errors to see more info"); } }