public static synchronized ZooReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) { if (instance == null) instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth); return instance; }
public DistributedWorkQueue(String path, AccumuloConfiguration config, long timerInitialDelay, long timerPeriod) { this.path = path; this.config = config; this.timerInitialDelay = timerInitialDelay; this.timerPeriod = timerPeriod; zoo = new ZooReaderWriter(config); }
/** * Gets a new reader/writer. * * @param string * ZooKeeper connection string * @param timeInMillis * session timeout in milliseconds * @param secret * instance secret * @return reader/writer */ public IZooReaderWriter getZooReaderWriter(String string, int timeInMillis, String secret) { return new ZooReaderWriter(string, timeInMillis, SCHEME, (USER + ":" + secret).getBytes(UTF_8)); } }
private ServerContext(ServerInfo info) { super(info, info.getSiteConfiguration()); this.info = info; zooReaderWriter = new ZooReaderWriter(info.getSiteConfiguration()); }
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()); }
@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 opts = new Opts(); opts.parseArgs(DumpZookeeper.class.getName(), args); Logger.getRootLogger().setLevel(Level.WARN); PrintStream out = System.out; try { zk = new ZooReaderWriter(opts.getSiteConfiguration()); if (opts.xml) { writeXml(out, opts.root); } else { writeHumanReadable(out, opts.root); } } catch (Exception ex) { log.error(ex, ex); } }
private static void verifyAccumuloIsDown(ServerContext context, String oldPassword) throws Exception { ZooReader zooReader = new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(), oldPassword); String root = context.getZooKeeperRoot(); final List<String> ephemerals = new ArrayList<>(); recurse(zooReader, root, new Visitor() { @Override public void visit(ZooReader zoo, String path) throws Exception { Stat stat = zoo.getStatus(path); if (stat.getEphemeralOwner() != 0) ephemerals.add(path); } }); if (ephemerals.size() > 0) { System.err.println("The following ephemeral nodes exist, something is still running:"); for (String path : ephemerals) { System.err.println(path); } throw new Exception("Accumulo must be shut down in order to run this tool."); } }
private static void deleteInstance(ServerContext context, String oldPass) throws Exception { IZooReaderWriter orig = new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(), oldPass); orig.recursiveDelete("/accumulo/" + context.getInstanceID(), NodeMissingPolicy.SKIP); } }
/** * @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); } }
private static void rewriteZooKeeperInstance(final ServerContext context, final String newInstanceId, String oldPass, String newPass) throws Exception { final ZooReaderWriter orig = new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(), oldPass); final IZooReaderWriter new_ = new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(), newPass);
setZooReaderWriter(new ZooReaderWriter(siteConfig)); SecurityUtil.serverLogin(siteConfig); Configuration hadoopConfig = new Configuration();
Path instanceDir = new Path(volDir, "instance_id"); String iid = ZooUtil.getInstanceIDFromHdfs(instanceDir, siteConf, hadoopConf); ZooReaderWriter zoo = new ZooReaderWriter(siteConf);
public static synchronized ZooReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) { if (instance == null) instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth); return instance; }
/** * Gets a new reader/writer. * * @param string * ZooKeeper connection string * @param timeInMillis * session timeout in milliseconds * @param secret * instance secret * @return reader/writer */ public IZooReaderWriter getZooReaderWriter(String string, int timeInMillis, String secret) { return new ZooReaderWriter(string, timeInMillis, SCHEME, (USER + ":" + secret).getBytes(UTF_8)); }
protected synchronized IZooReaderWriter getZooReaderWriter(Instance instance, String secret) { if (secret == null) { AccumuloConfiguration conf = SiteConfiguration.getInstance(); secret = conf.get(Property.INSTANCE_SECRET); } return new ZooReaderWriter(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), SCHEME, (USER + ":" + secret).getBytes()); }