Search in sources :

Example 11 with TExternalCompactionJob

use of org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob in project accumulo by apache.

the class CompactorTest method testCompactionFails.

@Test
public void testCompactionFails() throws Exception {
    UUID uuid = UUID.randomUUID();
    Supplier<UUID> supplier = () -> uuid;
    ExternalCompactionId eci = ExternalCompactionId.generate(supplier.get());
    PowerMock.resetAll();
    PowerMock.suppress(PowerMock.methods(Halt.class, "halt"));
    PowerMock.suppress(PowerMock.constructor(AbstractServer.class));
    ServerAddress client = PowerMock.createNiceMock(ServerAddress.class);
    HostAndPort address = HostAndPort.fromString("localhost:10240");
    EasyMock.expect(client.getAddress()).andReturn(address);
    TExternalCompactionJob job = PowerMock.createNiceMock(TExternalCompactionJob.class);
    TKeyExtent extent = PowerMock.createNiceMock(TKeyExtent.class);
    EasyMock.expect(extent.getTable()).andReturn("testTable".getBytes()).anyTimes();
    EasyMock.expect(job.isSetExternalCompactionId()).andReturn(true).anyTimes();
    EasyMock.expect(job.getExternalCompactionId()).andReturn(eci.toString()).anyTimes();
    EasyMock.expect(job.getExtent()).andReturn(extent).anyTimes();
    AccumuloConfiguration conf = PowerMock.createNiceMock(AccumuloConfiguration.class);
    EasyMock.expect(conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT)).andReturn(86400000L);
    ServerContext context = PowerMock.createNiceMock(ServerContext.class);
    EasyMock.expect(context.getConfiguration()).andReturn(conf);
    ZooReaderWriter zrw = PowerMock.createNiceMock(ZooReaderWriter.class);
    ZooKeeper zk = PowerMock.createNiceMock(ZooKeeper.class);
    EasyMock.expect(context.getZooReaderWriter()).andReturn(zrw).anyTimes();
    EasyMock.expect(zrw.getZooKeeper()).andReturn(zk).anyTimes();
    VolumeManagerImpl vm = PowerMock.createNiceMock(VolumeManagerImpl.class);
    EasyMock.expect(context.getVolumeManager()).andReturn(vm);
    vm.close();
    PowerMock.replayAll();
    FailedCompactor c = new FailedCompactor(supplier, client, job, conf, context, eci);
    c.run();
    PowerMock.verifyAll();
    c.close();
    assertFalse(c.isCompletedCalled());
    assertTrue(c.isFailedCalled());
    assertEquals(TCompactionState.FAILED, c.getLatestState());
}
Also used : Halt(org.apache.accumulo.core.util.Halt) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) ServerAddress(org.apache.accumulo.server.rpc.ServerAddress) ZooReaderWriter(org.apache.accumulo.fate.zookeeper.ZooReaderWriter) VolumeManagerImpl(org.apache.accumulo.server.fs.VolumeManagerImpl) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AbstractServer(org.apache.accumulo.server.AbstractServer) ZooKeeper(org.apache.zookeeper.ZooKeeper) ServerContext(org.apache.accumulo.server.ServerContext) UUID(java.util.UUID) TExternalCompactionJob(org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with TExternalCompactionJob

use of org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob in project accumulo by apache.

the class CompactorTest method testCompactionInterrupted.

@Test
public void testCompactionInterrupted() throws Exception {
    UUID uuid = UUID.randomUUID();
    Supplier<UUID> supplier = () -> uuid;
    ExternalCompactionId eci = ExternalCompactionId.generate(supplier.get());
    PowerMock.resetAll();
    PowerMock.suppress(PowerMock.methods(Halt.class, "halt"));
    PowerMock.suppress(PowerMock.constructor(AbstractServer.class));
    ServerAddress client = PowerMock.createNiceMock(ServerAddress.class);
    HostAndPort address = HostAndPort.fromString("localhost:10240");
    EasyMock.expect(client.getAddress()).andReturn(address);
    TExternalCompactionJob job = PowerMock.createNiceMock(TExternalCompactionJob.class);
    TKeyExtent extent = PowerMock.createNiceMock(TKeyExtent.class);
    EasyMock.expect(job.isSetExternalCompactionId()).andReturn(true).anyTimes();
    EasyMock.expect(job.getExternalCompactionId()).andReturn(eci.toString()).anyTimes();
    EasyMock.expect(job.getExtent()).andReturn(extent).anyTimes();
    EasyMock.expect(extent.getTable()).andReturn("testTable".getBytes()).anyTimes();
    AccumuloConfiguration conf = PowerMock.createNiceMock(AccumuloConfiguration.class);
    EasyMock.expect(conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT)).andReturn(86400000L);
    ServerContext context = PowerMock.createNiceMock(ServerContext.class);
    EasyMock.expect(context.getConfiguration()).andReturn(conf);
    ZooReaderWriter zrw = PowerMock.createNiceMock(ZooReaderWriter.class);
    ZooKeeper zk = PowerMock.createNiceMock(ZooKeeper.class);
    EasyMock.expect(context.getZooReaderWriter()).andReturn(zrw).anyTimes();
    EasyMock.expect(zrw.getZooKeeper()).andReturn(zk).anyTimes();
    VolumeManagerImpl vm = PowerMock.createNiceMock(VolumeManagerImpl.class);
    EasyMock.expect(context.getVolumeManager()).andReturn(vm);
    vm.close();
    PowerMock.replayAll();
    InterruptedCompactor c = new InterruptedCompactor(supplier, client, job, conf, context, eci);
    c.run();
    PowerMock.verifyAll();
    c.close();
    assertFalse(c.isCompletedCalled());
    assertTrue(c.isFailedCalled());
    assertEquals(TCompactionState.CANCELLED, c.getLatestState());
}
Also used : Halt(org.apache.accumulo.core.util.Halt) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) ServerAddress(org.apache.accumulo.server.rpc.ServerAddress) ZooReaderWriter(org.apache.accumulo.fate.zookeeper.ZooReaderWriter) VolumeManagerImpl(org.apache.accumulo.server.fs.VolumeManagerImpl) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AbstractServer(org.apache.accumulo.server.AbstractServer) ZooKeeper(org.apache.zookeeper.ZooKeeper) ServerContext(org.apache.accumulo.server.ServerContext) UUID(java.util.UUID) TExternalCompactionJob(org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with TExternalCompactionJob

use of org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob in project accumulo by apache.

the class ExternalCompactionJob method toThrift.

public TExternalCompactionJob toThrift() {
    IteratorConfig iteratorSettings = SystemIteratorUtil.toIteratorConfig(iters);
    List<InputFile> files = jobFiles.entrySet().stream().map(e -> {
        var dfv = e.getValue();
        return new InputFile(e.getKey().getPathStr(), dfv.getSize(), dfv.getNumEntries(), dfv.getTime());
    }).collect(Collectors.toList());
    return new TExternalCompactionJob(externalCompactionId.toString(), extent.toThrift(), files, iteratorSettings, compactTmpName.getPathStr(), propagateDeletes, org.apache.accumulo.core.tabletserver.thrift.TCompactionKind.valueOf(kind.name()), userCompactionId, overrides);
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) IteratorConfig(org.apache.accumulo.core.tabletserver.thrift.IteratorConfig) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Collectors(java.util.stream.Collectors) TExternalCompactionJob(org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob) Objects(java.util.Objects) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) List(java.util.List) SystemIteratorUtil(org.apache.accumulo.core.iteratorsImpl.system.SystemIteratorUtil) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) CompactionKind(org.apache.accumulo.core.spi.compaction.CompactionKind) InputFile(org.apache.accumulo.core.tabletserver.thrift.InputFile) Map(java.util.Map) TabletFile(org.apache.accumulo.core.metadata.TabletFile) Preconditions(com.google.common.base.Preconditions) TExternalCompactionJob(org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob) IteratorConfig(org.apache.accumulo.core.tabletserver.thrift.IteratorConfig) InputFile(org.apache.accumulo.core.tabletserver.thrift.InputFile)

Aggregations

TExternalCompactionJob (org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob)13 ExternalCompactionId (org.apache.accumulo.core.metadata.schema.ExternalCompactionId)7 HostAndPort (org.apache.accumulo.core.util.HostAndPort)7 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)6 AbstractServer (org.apache.accumulo.server.AbstractServer)6 ServerContext (org.apache.accumulo.server.ServerContext)6 ServerAddress (org.apache.accumulo.server.rpc.ServerAddress)6 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)4 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)4 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)3 TCredentials (org.apache.accumulo.core.securityImpl.thrift.TCredentials)3 Client (org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)3 Halt (org.apache.accumulo.core.util.Halt)3 RunningCompaction (org.apache.accumulo.core.util.compaction.RunningCompaction)3 ZooReaderWriter (org.apache.accumulo.fate.zookeeper.ZooReaderWriter)3