public synchronized ServerContext getServerContext() { if (context == null) { if (instance == null) { context = new ServerContext(new SiteConfiguration()); } else { context = new ServerContext(new SiteConfiguration(), getClientProperties()); } } return context; } }
public synchronized ServerContext getServerContext() { if (context == null) { if (instance == null) { context = new ServerContext(new SiteConfiguration()); } else { context = new ServerContext(new SiteConfiguration(), getClientProperties()); } } return context; } }
public static void main(String[] args) throws Exception { listVolumes(new ServerContext(new SiteConfiguration())); }
public static void main(String args[]) { ServerContext context = new ServerContext(new SiteConfiguration()); getInstance(context).printProblems(); }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "process runs in same security context as admin who provided path") public synchronized SiteConfiguration getSiteConfiguration() { if (siteConfig == null) { siteConfig = new SiteConfiguration(new File(getPropertiesPath()), getOverrides()); } return siteConfig; }
@Override public void execute(final String[] args) throws KeeperException, InterruptedException { ServerContext context = new ServerContext(new SiteConfiguration()); System.out.println("monitor: " + MonitorUtil.getLocation(context)); System.out.println("masters: " + context.getMasterLocations()); System.out.println("zookeepers: " + context.getZooKeepers()); }
public static void main(String[] args) { try (ServerContext context = new ServerContext(new SiteConfiguration())) { context.getServerConfFactory().getSystemConfiguration(); } }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who provided input") public static void main(String[] args) throws Exception { Logger.getRootLogger().setLevel(Level.WARN); Opts opts = new Opts(); opts.parseArgs(RestoreZookeeper.class.getName(), args); ZooReaderWriter zoo = new ZooReaderWriter(new SiteConfiguration()); InputStream in = System.in; if (opts.file != null) { in = new FileInputStream(opts.file); } SAXParserFactory factory = SAXParserFactory.newInstance(); // Prevent external entities by failing on any doctypes. We don't expect any doctypes, so this // is a simple switch to remove any chance of external entities causing problems. factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); SAXParser parser = factory.newSAXParser(); parser.parse(in, new Restore(zoo, opts.overwrite)); in.close(); } }
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); }
@Override public void execute(String[] args) throws Exception { try (ServerContext context = new ServerContext(new SiteConfiguration())) { AccumuloConfiguration config = context.getServerConfFactory().getSystemConfiguration(); Authenticator authenticator = AccumuloVFSClassLoader.getClassLoader() .loadClass(config.get(Property.INSTANCE_SECURITY_AUTHENTICATOR)) .asSubclass(Authenticator.class).newInstance(); List<Set<TokenProperty>> tokenProps = new ArrayList<>(); for (Class<? extends AuthenticationToken> tokenType : authenticator .getSupportedTokenTypes()) { tokenProps.add(tokenType.newInstance().getProperties()); } System.out .println("Supported token types for " + authenticator.getClass().getName() + " are : "); for (Class<? extends AuthenticationToken> tokenType : authenticator .getSupportedTokenTypes()) { System.out .println("\t" + tokenType.getName() + ", which accepts the following properties : "); for (TokenProperty tokenProperty : tokenType.newInstance().getProperties()) { System.out.println("\t\t" + tokenProperty); } System.out.println(); } } }
/** * Utility program that will change the goal state for the master from the command line. */ public static void main(String[] args) throws Exception { if (args.length != 1 || MasterGoalState.valueOf(args[0]) == null) { System.err.println( "Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]"); System.exit(-1); } ServerContext context = new ServerContext(new SiteConfiguration()); SecurityUtil.serverLogin(context.getConfiguration()); ServerUtil.waitForZookeeperAndHdfs(context); context.getZooReaderWriter().putPersistentData( context.getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }
public static void main(String[] args) throws Exception { SiteConfiguration siteConfig = new SiteConfiguration(); VolumeManager fs = VolumeManagerImpl.get(siteConfig, new Configuration()); verifyHdfsWritePermission(fs); Opts opts = new Opts(); List<String> argsList = new ArrayList<>(args.length + 2); argsList.add("--old"); argsList.add("--new"); argsList.addAll(Arrays.asList(args)); opts.parseArgs(ChangeSecret.class.getName(), argsList.toArray(new String[0])); ServerContext context = opts.getServerContext(); verifyAccumuloIsDown(context, opts.oldPass); final String newInstanceId = UUID.randomUUID().toString(); updateHdfs(fs, newInstanceId); rewriteZooKeeperInstance(context, newInstanceId, opts.oldPass, opts.newPass); if (opts.oldPass != null) { deleteInstance(context, opts.oldPass); } System.out.println("New instance id is " + newInstanceId); System.out.println("Be sure to put your new secret in accumulo.properties"); }
/** * @param args * : the name or UUID of the instance to be deleted */ public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(DeleteZooInstance.class.getName(), args); ZooReaderWriter zk = new ZooReaderWriter(new SiteConfiguration()); // try instance name: Set<String> instances = new HashSet<>(zk.getChildren(Constants.ZROOT + Constants.ZINSTANCES)); Set<String> uuids = new HashSet<>(zk.getChildren(Constants.ZROOT)); uuids.remove("instances"); if (instances.contains(opts.instance)) { String path = Constants.ZROOT + Constants.ZINSTANCES + "/" + opts.instance; byte[] data = zk.getData(path, null); deleteRetry(zk, path); deleteRetry(zk, Constants.ZROOT + "/" + new String(data, UTF_8)); } else if (uuids.contains(opts.instance)) { // look for the real instance name for (String instance : instances) { String path = Constants.ZROOT + Constants.ZINSTANCES + "/" + instance; byte[] data = zk.getData(path, null); if (opts.instance.equals(new String(data, UTF_8))) deleteRetry(zk, path); } deleteRetry(zk, Constants.ZROOT + "/" + opts.instance); } }
@Override public void execute(final String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(ZooKeeperMain.class.getName(), args); try (ServerContext context = new ServerContext(new SiteConfiguration())) { FileSystem fs = context.getVolumeManager().getDefaultVolume().getFileSystem(); String baseDir = ServerConstants.getBaseUris(context)[0]; System.out.println("Using " + fs.makeQualified(new Path(baseDir + "/instance_id")) + " to lookup accumulo instance"); if (opts.servers == null) { opts.servers = context.getZooKeepers(); } System.out.println("The accumulo instance id is " + context.getInstanceID()); if (!opts.servers.contains("/")) opts.servers += "/accumulo/" + context.getInstanceID(); org.apache.zookeeper.ZooKeeperMain .main(new String[] {"-server", opts.servers, "-timeout", "" + (opts.timeout * 1000)}); } } }
public static void main(String[] args) throws Exception { try (ServerContext context = new ServerContext(new SiteConfiguration())) { String tserverPath = context.getZooKeeperRoot() + Constants.ZTSERVERS; Opts opts = new Opts(); opts.parseArgs(TabletServerLocks.class.getName(), args); ZooCache cache = context.getZooCache(); ZooReaderWriter zoo = context.getZooReaderWriter(); if (opts.list) { List<String> tabletServers = zoo.getChildren(tserverPath); for (String tabletServer : tabletServers) { byte[] lockData = ZooLock.getLockData(cache, tserverPath + "/" + tabletServer, null); String holder = null; if (lockData != null) { holder = new String(lockData, UTF_8); } System.out.printf("%32s %16s%n", tabletServer, holder); } } else if (opts.delete != null) { ZooLock.deleteLock(zoo, tserverPath + "/" + args[1]); } else { System.out.println( "Usage : " + TabletServerLocks.class.getName() + " -list|-delete <tserver lock>"); } } }
@Override public MonitorLocation get() { // lazily set up path and zooCache (see comment in constructor) if (this.context == null) { this.context = new ServerContext(new SiteConfiguration()); this.path = context.getZooKeeperRoot() + Constants.ZMONITOR_LOG4J_ADDR; this.zooCache = context.getZooCache(); } // get the current location from the cache and update if necessary ZcStat stat = new ZcStat(); byte[] loc = zooCache.get(path, stat); // mzxid is 0 if location does not exist and the non-zero transaction id of the last // modification otherwise return new MonitorLocation(stat.getMzxid(), loc); } }
opts.parseArgs(CleanZookeeper.class.getName(), args); try (ServerContext context = new ServerContext(new SiteConfiguration())) {
try (ServerContext context = new ServerContext(new SiteConfiguration())) { final String zkRoot = context.getZooKeeperRoot(); String path = zkRoot + Constants.ZFATE;
Opts opts = new Opts(); opts.parseArgs(LogReader.class.getName(), args); SiteConfiguration siteConfig = new SiteConfiguration(); VolumeManager fs = VolumeManagerImpl.get(siteConfig, new Configuration());
Opts opts = new Opts(); opts.parseArgs("accumulo init", args); SiteConfiguration siteConfig = new SiteConfiguration();