Search in sources :

Example 6 with HostAndPort

use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.

the class TabletServer method startTabletClientService.

private HostAndPort startTabletClientService() throws UnknownHostException {
    // start listening for client connection last
    clientHandler = new ThriftClientHandler();
    Iface rpcProxy = RpcWrapper.service(clientHandler);
    final Processor<Iface> processor;
    if (ThriftServerType.SASL == getThriftServerType()) {
        Iface tcredProxy = TCredentialsUpdatingWrapper.service(rpcProxy, ThriftClientHandler.class, getConfiguration());
        processor = new Processor<>(tcredProxy);
    } else {
        processor = new Processor<>(rpcProxy);
    }
    HostAndPort address = startServer(getServerConfigurationFactory().getSystemConfiguration(), clientAddress.getHost(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server");
    log.info("address = {}", address);
    return address;
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) Iface(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface)

Example 7 with HostAndPort

use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.

the class AccumuloReplicaSystem method _replicate.

/**
 * Perform replication, making a few attempts when an exception is returned.
 *
 * @param p
 *          Path of WAL to replicate
 * @param status
 *          Current status for the WAL
 * @param target
 *          Where we're replicating to
 * @param helper
 *          A helper for replication
 * @param localConf
 *          The local instance's configuration
 * @param peerContext
 *          The ClientContext to connect to the peer
 * @return The new (or unchanged) Status for the WAL
 */
private Status _replicate(final Path p, final Status status, final ReplicationTarget target, final ReplicaSystemHelper helper, final AccumuloConfiguration localConf, final ClientContext peerContext, final UserGroupInformation accumuloUgi) {
    try {
        double tracePercent = localConf.getFraction(Property.REPLICATION_TRACE_PERCENT);
        ProbabilitySampler sampler = new ProbabilitySampler(tracePercent);
        Trace.on("AccumuloReplicaSystem", sampler);
        // Remote identifier is an integer (table id) in this case.
        final String remoteTableId = target.getRemoteIdentifier();
        // Attempt the replication of this status a number of times before giving up and
        // trying to replicate it again later some other time.
        int numAttempts = localConf.getCount(Property.REPLICATION_WORK_ATTEMPTS);
        for (int i = 0; i < numAttempts; i++) {
            log.debug("Attempt {}", i);
            String peerTserverStr;
            log.debug("Fetching peer tserver address");
            Span span = Trace.start("Fetch peer tserver");
            try {
                // Ask the master on the remote what TServer we should talk with to replicate the data
                peerTserverStr = ReplicationClient.executeCoordinatorWithReturn(peerContext, new ClientExecReturn<String, ReplicationCoordinator.Client>() {

                    @Override
                    public String execute(ReplicationCoordinator.Client client) throws Exception {
                        return client.getServicerAddress(remoteTableId, peerContext.rpcCreds());
                    }
                });
            } catch (AccumuloException | AccumuloSecurityException e) {
                // No progress is made
                log.error("Could not connect to master at {}, cannot proceed with replication. Will retry", target, e);
                continue;
            } finally {
                span.stop();
            }
            if (null == peerTserverStr) {
                // Something went wrong, and we didn't get a valid tserver from the remote for some reason
                log.warn("Did not receive tserver from master at {}, cannot proceed with replication. Will retry.", target);
                continue;
            }
            final HostAndPort peerTserver = HostAndPort.fromString(peerTserverStr);
            final long timeout = localConf.getTimeInMillis(Property.REPLICATION_RPC_TIMEOUT);
            // We have a tserver on the remote -- send the data its way.
            Status finalStatus;
            final long sizeLimit = conf.getAsBytes(Property.REPLICATION_MAX_UNIT_SIZE);
            try {
                if (p.getName().endsWith(RFILE_SUFFIX)) {
                    span = Trace.start("RFile replication");
                    try {
                        finalStatus = replicateRFiles(peerContext, peerTserver, target, p, status, sizeLimit, remoteTableId, peerContext.rpcCreds(), helper, timeout);
                    } finally {
                        span.stop();
                    }
                } else {
                    span = Trace.start("WAL replication");
                    try {
                        finalStatus = replicateLogs(peerContext, peerTserver, target, p, status, sizeLimit, remoteTableId, peerContext.rpcCreds(), helper, accumuloUgi, timeout);
                    } finally {
                        span.stop();
                    }
                }
                log.debug("New status for {} after replicating to {} is {}", p, peerContext.getInstance(), ProtobufUtil.toString(finalStatus));
                return finalStatus;
            } catch (TTransportException | AccumuloException | AccumuloSecurityException e) {
                log.warn("Could not connect to remote server {}, will retry", peerTserverStr, e);
                sleepUninterruptibly(1, TimeUnit.SECONDS);
            }
        }
        log.info("No progress was made after {} attempts to replicate {}, returning so file can be re-queued", numAttempts, p);
        // We made no status, punt on it for now, and let it re-queue itself for work
        return status;
    } finally {
        Trace.off();
    }
}
Also used : ProbabilitySampler(org.apache.accumulo.core.trace.ProbabilitySampler) Status(org.apache.accumulo.server.replication.proto.Replication.Status) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ClientExecReturn(org.apache.accumulo.core.client.impl.ClientExecReturn) TTransportException(org.apache.thrift.transport.TTransportException) ReplicationCoordinator(org.apache.accumulo.core.replication.thrift.ReplicationCoordinator) Span(org.apache.accumulo.core.trace.Span) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Client(org.apache.accumulo.core.replication.thrift.ReplicationServicer.Client) ReplicationClient(org.apache.accumulo.core.client.impl.ReplicationClient)

Example 8 with HostAndPort

use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.

the class LiveTServerSet method checkServer.

private synchronized void checkServer(final Set<TServerInstance> updates, final Set<TServerInstance> doomed, final String path, final String zPath) throws TException, InterruptedException, KeeperException {
    TServerInfo info = current.get(zPath);
    final String lockPath = path + "/" + zPath;
    ZcStat stat = new ZcStat();
    byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
    if (lockData == null) {
        if (info != null) {
            doomed.add(info.instance);
            current.remove(zPath);
            currentInstances.remove(info.instance);
        }
        Long firstSeen = locklessServers.get(zPath);
        if (firstSeen == null) {
            locklessServers.put(zPath, System.currentTimeMillis());
        } else if (System.currentTimeMillis() - firstSeen > 10 * 60 * 1000) {
            deleteServerNode(path + "/" + zPath);
            locklessServers.remove(zPath);
        }
    } else {
        locklessServers.remove(zPath);
        ServerServices services = new ServerServices(new String(lockData, UTF_8));
        HostAndPort client = services.getAddress(ServerServices.Service.TSERV_CLIENT);
        TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
        if (info == null) {
            updates.add(instance);
            TServerInfo tServerInfo = new TServerInfo(instance, new TServerConnection(client));
            current.put(zPath, tServerInfo);
            currentInstances.put(instance, tServerInfo);
        } else if (!info.instance.equals(instance)) {
            doomed.add(info.instance);
            updates.add(instance);
            TServerInfo tServerInfo = new TServerInfo(instance, new TServerConnection(client));
            current.put(zPath, tServerInfo);
            currentInstances.remove(info.instance);
            currentInstances.put(instance, tServerInfo);
        }
    }
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) ZcStat(org.apache.accumulo.fate.zookeeper.ZooCache.ZcStat) ServerServices(org.apache.accumulo.core.util.ServerServices) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance)

Example 9 with HostAndPort

use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.

the class ZooTabletStateStore method parse.

protected TServerInstance parse(byte[] current) {
    String str = new String(current, UTF_8);
    String[] parts = str.split("[|]", 2);
    HostAndPort address = HostAndPort.fromString(parts[0]);
    if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) {
        return new TServerInstance(address, parts[1]);
    } else {
        // a 1.2 location specification: DO NOT WANT
        return null;
    }
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort)

Example 10 with HostAndPort

use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.

the class Monitor method fetchGcStatus.

private static GCStatus fetchGcStatus() {
    GCStatus result = null;
    HostAndPort address = null;
    try {
        // Read the gc location from its lock
        ZooReaderWriter zk = ZooReaderWriter.getInstance();
        String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK;
        List<String> locks = zk.getChildren(path, null);
        if (locks != null && locks.size() > 0) {
            Collections.sort(locks);
            address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8)).getAddress(Service.GC_CLIENT);
            GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, new AccumuloServerContext(instance, config));
            try {
                result = client.getStatus(Tracer.traceInfo(), getContext().rpcCreds());
            } finally {
                ThriftUtil.returnClient(client);
            }
        }
    } catch (Exception ex) {
        log.warn("Unable to contact the garbage collector at " + address, ex);
    }
    return result;
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) ServerServices(org.apache.accumulo.core.util.ServerServices) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) GCMonitorService(org.apache.accumulo.core.gc.thrift.GCMonitorService) MasterClient(org.apache.accumulo.core.client.impl.MasterClient) Client(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client) KeeperException(org.apache.zookeeper.KeeperException) UnknownHostException(java.net.UnknownHostException)

Aggregations

HostAndPort (org.apache.accumulo.core.util.HostAndPort)38 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)12 ArrayList (java.util.ArrayList)11 TTransportException (org.apache.thrift.transport.TTransportException)10 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)8 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)8 TException (org.apache.thrift.TException)8 UnknownHostException (java.net.UnknownHostException)7 IOException (java.io.IOException)6 Instance (org.apache.accumulo.core.client.Instance)6 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)6 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)6 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)6 KeeperException (org.apache.zookeeper.KeeperException)6 Test (org.junit.Test)6 Connector (org.apache.accumulo.core.client.Connector)5 Client (org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)5 MasterClient (org.apache.accumulo.core.client.impl.MasterClient)4 Text (org.apache.hadoop.io.Text)4