Search in sources :

Example 26 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class Admin method execute.

@Override
public void execute(final String[] args) {
    boolean everything;
    AdminOpts opts = new AdminOpts();
    JCommander cl = new JCommander(opts);
    cl.setProgramName("accumulo admin");
    CheckTabletsCommand checkTabletsCommand = new CheckTabletsCommand();
    cl.addCommand("checkTablets", checkTabletsCommand);
    ListInstancesCommand listIntancesOpts = new ListInstancesCommand();
    cl.addCommand("listInstances", listIntancesOpts);
    PingCommand pingCommand = new PingCommand();
    cl.addCommand("ping", pingCommand);
    DumpConfigCommand dumpConfigCommand = new DumpConfigCommand();
    cl.addCommand("dumpConfig", dumpConfigCommand);
    VolumesCommand volumesCommand = new VolumesCommand();
    cl.addCommand("volumes", volumesCommand);
    StopCommand stopOpts = new StopCommand();
    cl.addCommand("stop", stopOpts);
    StopAllCommand stopAllOpts = new StopAllCommand();
    cl.addCommand("stopAll", stopAllOpts);
    StopMasterCommand stopMasterOpts = new StopMasterCommand();
    cl.addCommand("stopMaster", stopMasterOpts);
    RandomizeVolumesCommand randomizeVolumesOpts = new RandomizeVolumesCommand();
    cl.addCommand("randomizeVolumes", randomizeVolumesOpts);
    cl.parse(args);
    if (opts.help || cl.getParsedCommand() == null) {
        cl.usage();
        return;
    }
    AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
    // Login as the server on secure HDFS
    if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
        SecurityUtil.serverLogin(siteConf);
    }
    Instance instance = opts.getInstance();
    ServerConfigurationFactory confFactory = new ServerConfigurationFactory(instance);
    try {
        ClientContext context = new AccumuloServerContext(instance, confFactory);
        int rc = 0;
        if (cl.getParsedCommand().equals("listInstances")) {
            ListInstances.listInstances(instance.getZooKeepers(), listIntancesOpts.printAll, listIntancesOpts.printErrors);
        } else if (cl.getParsedCommand().equals("ping")) {
            if (ping(context, pingCommand.args) != 0)
                rc = 4;
        } else if (cl.getParsedCommand().equals("checkTablets")) {
            System.out.println("\n*** Looking for offline tablets ***\n");
            if (FindOfflineTablets.findOffline(context, checkTabletsCommand.tableName) != 0)
                rc = 5;
            System.out.println("\n*** Looking for missing files ***\n");
            if (checkTabletsCommand.tableName == null) {
                if (RemoveEntriesForMissingFiles.checkAllTables(context, checkTabletsCommand.fixFiles) != 0)
                    rc = 6;
            } else {
                if (RemoveEntriesForMissingFiles.checkTable(context, checkTabletsCommand.tableName, checkTabletsCommand.fixFiles) != 0)
                    rc = 6;
            }
        } else if (cl.getParsedCommand().equals("stop")) {
            stopTabletServer(context, stopOpts.args, opts.force);
        } else if (cl.getParsedCommand().equals("dumpConfig")) {
            printConfig(context, dumpConfigCommand);
        } else if (cl.getParsedCommand().equals("volumes")) {
            ListVolumesUsed.listVolumes(context);
        } else if (cl.getParsedCommand().equals("randomizeVolumes")) {
            rc = RandomizeVolumes.randomize(context.getConnector(), randomizeVolumesOpts.tableName);
        } else {
            everything = cl.getParsedCommand().equals("stopAll");
            if (everything)
                flushAll(context);
            stopServer(context, everything);
        }
        if (rc != 0)
            System.exit(rc);
    } catch (AccumuloException e) {
        log.error("{}", e.getMessage(), e);
        System.exit(1);
    } catch (AccumuloSecurityException e) {
        log.error("{}", e.getMessage(), e);
        System.exit(2);
    } catch (Exception e) {
        log.error("{}", e.getMessage(), e);
        System.exit(3);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Instance(org.apache.accumulo.core.client.Instance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) JCommander(com.beust.jcommander.JCommander) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 27 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class TabletServer method main.

public static void main(String[] args) throws IOException {
    try {
        final String app = "tserver";
        ServerOpts opts = new ServerOpts();
        opts.parseArgs(app, args);
        SecurityUtil.serverLogin(SiteConfiguration.getInstance());
        String hostname = opts.getAddress();
        Instance instance = HdfsZooInstance.getInstance();
        ServerConfigurationFactory conf = new ServerConfigurationFactory(instance);
        VolumeManager fs = VolumeManagerImpl.get();
        MetricsSystemHelper.configure(TabletServer.class.getSimpleName());
        Accumulo.init(fs, instance, conf, app);
        final TabletServer server = new TabletServer(instance, conf, fs);
        server.config(hostname);
        DistributedTrace.enable(hostname, app, conf.getSystemConfiguration());
        if (UserGroupInformation.isSecurityEnabled()) {
            UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
            loginUser.doAs(new PrivilegedExceptionAction<Void>() {

                @Override
                public Void run() {
                    server.run();
                    return null;
                }
            });
        } else {
            server.run();
        }
    } catch (Exception ex) {
        log.error("Uncaught exception in TabletServer.main, exiting", ex);
        System.exit(1);
    } finally {
        DistributedTrace.disable();
    }
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ServerOpts(org.apache.accumulo.server.ServerOpts) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) IterationInterruptedException(org.apache.accumulo.core.iterators.IterationInterruptedException) TSampleNotPresentException(org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException) WalMarkerException(org.apache.accumulo.server.log.WalStateManager.WalMarkerException) ConstraintViolationException(org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) KeeperException(org.apache.zookeeper.KeeperException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) CancellationException(java.util.concurrent.CancellationException) DistributedStoreException(org.apache.accumulo.server.master.state.DistributedStoreException) TException(org.apache.thrift.TException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) BadLocationStateException(org.apache.accumulo.server.master.state.TabletLocationState.BadLocationStateException) TimeoutException(java.util.concurrent.TimeoutException) TabletClosedException(org.apache.accumulo.tserver.tablet.TabletClosedException) SampleNotPresentException(org.apache.accumulo.core.client.SampleNotPresentException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 28 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class TraceServer method main.

public static void main(String[] args) throws Exception {
    final String app = "tracer";
    ServerOpts opts = new ServerOpts();
    opts.parseArgs(app, args);
    loginTracer(SiteConfiguration.getInstance());
    Instance instance = HdfsZooInstance.getInstance();
    ServerConfigurationFactory conf = new ServerConfigurationFactory(instance);
    VolumeManager fs = VolumeManagerImpl.get();
    MetricsSystemHelper.configure(TraceServer.class.getSimpleName());
    Accumulo.init(fs, instance, conf, app);
    String hostname = opts.getAddress();
    TraceServer server = new TraceServer(instance, conf, hostname);
    try {
        server.run();
    } finally {
        log.info("tracer stopping");
        ZooReaderWriter.getInstance().getZooKeeper().close();
    }
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ServerOpts(org.apache.accumulo.server.ServerOpts) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Example 29 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class ListBulkCommand method execute.

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    List<String> tservers;
    MasterMonitorInfo stats;
    MasterClientService.Iface client = null;
    Instance instance = shellState.getInstance();
    AccumuloServerContext context = new AccumuloServerContext(instance, new ServerConfigurationFactory(instance));
    while (true) {
        try {
            client = MasterClient.getConnectionWithRetry(context);
            stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
            break;
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } finally {
            if (client != null)
                MasterClient.close(client);
        }
    }
    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
    if (cl.hasOption(tserverOption.getOpt())) {
        tservers = new ArrayList<>();
        tservers.add(cl.getOptionValue(tserverOption.getOpt()));
    } else {
        tservers = Collections.emptyList();
    }
    shellState.printLines(new BulkImportListIterator(tservers, stats), paginate);
    return 0;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) Instance(org.apache.accumulo.core.client.Instance) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Example 30 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class NullTserver method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    opts.parseArgs(NullTserver.class.getName(), args);
    // modify metadata
    ZooKeeperInstance zki = new ZooKeeperInstance(ClientConfiguration.create().withInstance(opts.iname).withZkHosts(opts.keepers));
    Instance inst = HdfsZooInstance.getInstance();
    AccumuloServerContext context = new AccumuloServerContext(inst, new ServerConfigurationFactory(zki));
    TransactionWatcher watcher = new TransactionWatcher();
    ThriftClientHandler tch = new ThriftClientHandler(new AccumuloServerContext(inst, new ServerConfigurationFactory(inst)), watcher);
    Processor<Iface> processor = new Processor<>(tch);
    TServerUtils.startTServer(context.getConfiguration(), ThriftServerType.CUSTOM_HS_HA, processor, "NullTServer", "null tserver", 2, 1, 1000, 10 * 1024 * 1024, null, null, -1, HostAndPort.fromParts("0.0.0.0", opts.port));
    HostAndPort addr = HostAndPort.fromParts(InetAddress.getLocalHost().getHostName(), opts.port);
    Table.ID tableId = Tables.getTableId(zki, opts.tableName);
    // read the locations for the table
    Range tableRange = new KeyExtent(tableId, null, null).toMetadataRange();
    List<Assignment> assignments = new ArrayList<>();
    try (MetaDataTableScanner s = new MetaDataTableScanner(context, tableRange)) {
        long randomSessionID = opts.port;
        TServerInstance instance = new TServerInstance(addr, randomSessionID);
        while (s.hasNext()) {
            TabletLocationState next = s.next();
            assignments.add(new Assignment(next.extent, instance));
        }
    }
    // point them to this server
    MetaDataStateStore store = new MetaDataStateStore(context);
    store.setLocations(assignments);
    while (true) {
        sleepUninterruptibly(10, TimeUnit.SECONDS);
    }
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Processor(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Processor) Table(org.apache.accumulo.core.client.impl.Table) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ArrayList(java.util.ArrayList) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) TRowRange(org.apache.accumulo.core.data.thrift.TRowRange) TRange(org.apache.accumulo.core.data.thrift.TRange) Range(org.apache.accumulo.core.data.Range) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) Assignment(org.apache.accumulo.server.master.state.Assignment) MetaDataStateStore(org.apache.accumulo.server.master.state.MetaDataStateStore) HostAndPort(org.apache.accumulo.core.util.HostAndPort) Iface(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface) TransactionWatcher(org.apache.accumulo.server.zookeeper.TransactionWatcher) MetaDataTableScanner(org.apache.accumulo.server.master.state.MetaDataTableScanner) TabletLocationState(org.apache.accumulo.server.master.state.TabletLocationState)

Aggregations

ServerConfigurationFactory (org.apache.accumulo.server.conf.ServerConfigurationFactory)30 Instance (org.apache.accumulo.core.client.Instance)23 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)17 HdfsZooInstance (org.apache.accumulo.server.client.HdfsZooInstance)13 IOException (java.io.IOException)8 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)8 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)8 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 SiteConfiguration (org.apache.accumulo.core.conf.SiteConfiguration)6 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)6 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 ServerOpts (org.apache.accumulo.server.ServerOpts)5 KeeperException (org.apache.zookeeper.KeeperException)5 ArrayList (java.util.ArrayList)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)4 Connector (org.apache.accumulo.core.client.Connector)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)4 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)4 Table (org.apache.accumulo.core.client.impl.Table)4 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)4