Search in sources :

Example 1 with Manager

use of org.apache.accumulo.manager.Manager in project accumulo by apache.

the class PrepBulkImport method checkForMerge.

private void checkForMerge(final long tid, final Manager manager) throws Exception {
    VolumeManager fs = manager.getVolumeManager();
    final Path bulkDir = new Path(bulkInfo.sourceDir);
    int maxTablets = Integer.parseInt(manager.getContext().getTableConfiguration(bulkInfo.tableId).get(Property.TABLE_BULK_MAX_TABLETS));
    try (LoadMappingIterator lmi = BulkSerialize.readLoadMapping(bulkDir.toString(), bulkInfo.tableId, fs::open)) {
        TabletIterFactory tabletIterFactory = startRow -> TabletsMetadata.builder(manager.getContext()).forTable(bulkInfo.tableId).overlapping(startRow, null).checkConsistency().fetch(PREV_ROW).build().stream().map(TabletMetadata::getExtent).iterator();
        sanityCheckLoadMapping(bulkInfo.tableId.canonical(), lmi, tabletIterFactory, maxTablets, tid);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) TableId(org.apache.accumulo.core.data.TableId) TabletsMetadata(org.apache.accumulo.core.metadata.schema.TabletsMetadata) LoggerFactory(org.slf4j.LoggerFactory) Text(org.apache.hadoop.io.Text) HashMap(java.util.HashMap) BulkImport(org.apache.accumulo.core.clientImpl.bulk.BulkImport) FileStatus(org.apache.hadoop.fs.FileStatus) Function(java.util.function.Function) TabletMetadata(org.apache.accumulo.core.metadata.schema.TabletMetadata) Repo(org.apache.accumulo.fate.Repo) Manager(org.apache.accumulo.manager.Manager) Map(java.util.Map) UniqueNameAllocator(org.apache.accumulo.server.tablets.UniqueNameAllocator) Path(org.apache.hadoop.fs.Path) TableOperationExceptionType(org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType) PREV_ROW(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator) Property(org.apache.accumulo.core.conf.Property) AcceptableThriftTableOperationException(org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ServerContext(org.apache.accumulo.server.ServerContext) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) IOException(java.io.IOException) TransactionWatcher(org.apache.accumulo.server.zookeeper.TransactionWatcher) Constants(org.apache.accumulo.core.Constants) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) TableOperation(org.apache.accumulo.core.clientImpl.thrift.TableOperation) List(java.util.List) TreeMap(java.util.TreeMap) BulkSerialize(org.apache.accumulo.core.clientImpl.bulk.BulkSerialize) Utils(org.apache.accumulo.manager.tableOps.Utils) UtilWaitThread.sleepUninterruptibly(org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly) VisibleForTesting(com.google.common.annotations.VisibleForTesting) FilenameUtils(org.apache.commons.io.FilenameUtils) ManagerRepo(org.apache.accumulo.manager.tableOps.ManagerRepo) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator)

Example 2 with Manager

use of org.apache.accumulo.manager.Manager in project accumulo by apache.

the class FateIT method testTransactionStatus.

@Test(timeout = 30000)
public void testTransactionStatus() throws Exception {
    ZooReaderWriter zk = new ZooReaderWriter(szk.getConn(), 30000, "secret");
    zk.mkdirs(ZK_ROOT + Constants.ZFATE);
    zk.mkdirs(ZK_ROOT + Constants.ZTABLE_LOCKS);
    zk.mkdirs(ZK_ROOT + Constants.ZNAMESPACES + "/" + NS.canonical());
    zk.mkdirs(ZK_ROOT + Constants.ZTABLE_STATE + "/" + TID.canonical());
    zk.mkdirs(ZK_ROOT + Constants.ZTABLES + "/" + TID.canonical());
    ZooStore<Manager> zooStore = new ZooStore<Manager>(ZK_ROOT + Constants.ZFATE, zk);
    final AgeOffStore<Manager> store = new AgeOffStore<Manager>(zooStore, 1000 * 60 * 60 * 8, System::currentTimeMillis);
    Manager manager = createMock(Manager.class);
    ServerContext sctx = createMock(ServerContext.class);
    expect(manager.getContext()).andReturn(sctx).anyTimes();
    expect(sctx.getZooKeeperRoot()).andReturn(ZK_ROOT).anyTimes();
    expect(sctx.getZooReaderWriter()).andReturn(zk).anyTimes();
    replay(manager, sctx);
    Fate<Manager> fate = new Fate<Manager>(manager, store, TraceRepo::toLogString);
    try {
        ConfigurationCopy config = new ConfigurationCopy();
        config.set(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE, "2");
        config.set(Property.MANAGER_FATE_THREADPOOL_SIZE, "1");
        fate.startTransactionRunners(config);
        // Wait for the transaction runner to be scheduled.
        UtilWaitThread.sleep(3000);
        callStarted = new CountDownLatch(1);
        finishCall = new CountDownLatch(1);
        long txid = fate.startTransaction();
        assertEquals(TStatus.NEW, getTxStatus(zk, txid));
        fate.seedTransaction(txid, new TestOperation(NS, TID), true, "Test Op");
        assertEquals(TStatus.SUBMITTED, getTxStatus(zk, txid));
        // wait for call() to be called
        callStarted.await();
        assertEquals(TStatus.IN_PROGRESS, getTxStatus(zk, txid));
        // tell the op to exit the method
        finishCall.countDown();
        // Check that it transitions to SUCCESSFUL
        TStatus s = getTxStatus(zk, txid);
        while (s != TStatus.SUCCESSFUL) {
            s = getTxStatus(zk, txid);
            Thread.sleep(10);
        }
        // Check that it gets removed
        boolean errorSeen = false;
        while (!errorSeen) {
            try {
                s = getTxStatus(zk, txid);
                Thread.sleep(10);
            } catch (KeeperException e) {
                if (e.code() == KeeperException.Code.NONODE) {
                    errorSeen = true;
                } else {
                    fail("Unexpected error thrown: " + e.getMessage());
                }
            }
        }
    } finally {
        fate.shutdown();
    }
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) ZooReaderWriter(org.apache.accumulo.fate.zookeeper.ZooReaderWriter) ZooStore(org.apache.accumulo.fate.ZooStore) TraceRepo(org.apache.accumulo.manager.tableOps.TraceRepo) Manager(org.apache.accumulo.manager.Manager) CountDownLatch(java.util.concurrent.CountDownLatch) Fate(org.apache.accumulo.fate.Fate) ServerContext(org.apache.accumulo.server.ServerContext) TStatus(org.apache.accumulo.fate.ReadOnlyTStore.TStatus) AgeOffStore(org.apache.accumulo.fate.AgeOffStore) KeeperException(org.apache.zookeeper.KeeperException) Test(org.junit.Test)

Example 3 with Manager

use of org.apache.accumulo.manager.Manager in project accumulo by apache.

the class ReplicationOperationsImplIT method getReplicationOperations.

/**
 * Spoof out the Manager so we can call the implementation without starting a full instance.
 */
private ReplicationOperationsImpl getReplicationOperations() {
    Manager manager = EasyMock.createMock(Manager.class);
    EasyMock.expect(manager.getContext()).andReturn(context).anyTimes();
    EasyMock.replay(manager);
    final ManagerClientServiceHandler mcsh = new ManagerClientServiceHandler(manager) {

        @Override
        protected TableId getTableId(ClientContext context, String tableName) {
            try {
                return TableId.of(client.tableOperations().tableIdMap().get(tableName));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    ClientContext context = (ClientContext) client;
    return new ReplicationOperationsImpl(context) {

        @Override
        protected boolean getManagerDrain(final TInfo tinfo, final TCredentials rpcCreds, final String tableName, final Set<String> wals) {
            try {
                return mcsh.drainReplicationTable(tinfo, rpcCreds, tableName, wals);
            } catch (TException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TException(org.apache.thrift.TException) Set(java.util.Set) ManagerClientServiceHandler(org.apache.accumulo.manager.ManagerClientServiceHandler) TCredentials(org.apache.accumulo.core.securityImpl.thrift.TCredentials) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) Manager(org.apache.accumulo.manager.Manager) TException(org.apache.thrift.TException) ReplicationOperationsImpl(org.apache.accumulo.core.clientImpl.ReplicationOperationsImpl)

Example 4 with Manager

use of org.apache.accumulo.manager.Manager in project accumulo by apache.

the class ManagerReplicationCoordinatorTest method randomServer.

@Test
public void randomServer() {
    Manager manager = EasyMock.createMock(Manager.class);
    ZooReader reader = EasyMock.createMock(ZooReader.class);
    ServerContext context = EasyMock.createMock(ServerContext.class);
    EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
    EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
    EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
    EasyMock.expect(manager.getContext()).andReturn(context);
    EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
    EasyMock.replay(manager, context, reader);
    ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
    TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
    assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 0));
}
Also used : ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) ServerContext(org.apache.accumulo.server.ServerContext) Manager(org.apache.accumulo.manager.Manager) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Example 5 with Manager

use of org.apache.accumulo.manager.Manager in project accumulo by apache.

the class ManagerReplicationCoordinatorTest method invalidOffset.

@Test
public void invalidOffset() {
    Manager manager = EasyMock.createMock(Manager.class);
    ServerContext context = EasyMock.createMock(ServerContext.class);
    EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
    EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
    EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
    ZooReader reader = EasyMock.createMock(ZooReader.class);
    EasyMock.expect(manager.getContext()).andReturn(context);
    EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
    EasyMock.replay(manager, context, reader);
    ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
    TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
    assertThrows(IllegalArgumentException.class, () -> coordinator.getRandomTServer(Collections.singleton(inst1), 1));
}
Also used : ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) ServerContext(org.apache.accumulo.server.ServerContext) Manager(org.apache.accumulo.manager.Manager) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Aggregations

Manager (org.apache.accumulo.manager.Manager)15 ServerContext (org.apache.accumulo.server.ServerContext)10 Test (org.junit.Test)9 TableId (org.apache.accumulo.core.data.TableId)5 ZooReaderWriter (org.apache.accumulo.fate.zookeeper.ZooReaderWriter)5 Path (org.apache.hadoop.fs.Path)5 AcceptableThriftTableOperationException (org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException)4 TableOperation (org.apache.accumulo.core.clientImpl.thrift.TableOperation)4 TableOperationExceptionType (org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType)4 NamespaceId (org.apache.accumulo.core.data.NamespaceId)4 Repo (org.apache.accumulo.fate.Repo)4 ManagerRepo (org.apache.accumulo.manager.tableOps.ManagerRepo)4 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 IOException (java.io.IOException)3 Set (java.util.Set)3 Constants (org.apache.accumulo.core.Constants)3 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)3 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)2