diff --git a/core/src/main/java/org/apache/accumulo/core/Constants.java b/core/src/main/java/org/apache/accumulo/core/Constants.java index ea06bc4ad79..eb8ba1059eb 100644 --- a/core/src/main/java/org/apache/accumulo/core/Constants.java +++ b/core/src/main/java/org/apache/accumulo/core/Constants.java @@ -49,6 +49,7 @@ public class Constants { public static final String ZMANAGERS = "/managers"; public static final String ZMANAGER_LOCK = ZMANAGERS + "/lock"; + public static final String ZMANAGER_ASSISTANT_LOCK = ZMANAGERS + "/assistants"; public static final String ZMANAGER_GOAL_STATE = ZMANAGERS + "/goal_state"; public static final String ZMANAGER_TICK = ZMANAGERS + "/tick"; diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/servers/ServerId.java b/core/src/main/java/org/apache/accumulo/core/client/admin/servers/ServerId.java index 19182bc7c92..beef589c07f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/servers/ServerId.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/servers/ServerId.java @@ -38,7 +38,7 @@ public final class ServerId implements Comparable { * @since 4.0.0 */ public enum Type { - MANAGER, MONITOR, GARBAGE_COLLECTOR, COMPACTOR, SCAN_SERVER, TABLET_SERVER; + MANAGER, MANAGER_ASSISTANT, MONITOR, GARBAGE_COLLECTOR, COMPACTOR, SCAN_SERVER, TABLET_SERVER; } private final Type type; diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java index 41674ebca71..ac75c7dc65a 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java @@ -1292,7 +1292,7 @@ private static Set createPersistentWatcherPaths() { Constants.ZMANAGER_LOCK, Constants.ZMINI_LOCK, Constants.ZMONITOR_LOCK, Constants.ZNAMESPACES, Constants.ZRECOVERY, Constants.ZSSERVERS, Constants.ZTABLES, Constants.ZTSERVERS, Constants.ZUSERS, RootTable.ZROOT_TABLET, Constants.ZTEST_LOCK, - Constants.ZRESOURCEGROUPS)) { + Constants.ZMANAGER_ASSISTANT_LOCK, Constants.ZRESOURCEGROUPS)) { pathsToWatch.add(path); } return pathsToWatch; diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java index dd311d2eda0..89d8ee6d39e 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java @@ -401,6 +401,17 @@ was changed and it now can accept multiple class names. The metrics spi was intr "Properties in this category affect the behavior of the manager server.", "2.1.0"), MANAGER_CLIENTPORT("manager.port.client", "9999", PropertyType.PORT, "The port used for handling client connections on the manager.", "1.3.5"), + MANAGER_ASSISTANT_PORT("manager.assistant.port", "10000", PropertyType.PORT, + "The port used by the primary manager to assign task to all manager processes.", "4.0.0"), + MANAGER_ASSISTANT_PORTSEARCH("manager.assistant.port.search", "true", PropertyType.BOOLEAN, + "if the manager.assistant.port ports are in use, search higher ports until one is available.", + "4.0.0"), + MANAGER_ASSISTANT_MINTHREADS("manager.assistant.server.threads.minimum", "20", PropertyType.COUNT, + "The minimum number of threads to use to handle incoming requests.", "4.0.0"), + MANAGER_ASSISTANT_MINTHREADS_TIMEOUT("manager.assistant.server.threads.timeout", "0s", + PropertyType.TIMEDURATION, + "The time after which incoming request threads terminate with no work available. Zero (0) will keep the threads alive indefinitely.", + "4.0.0"), MANAGER_TABLET_BALANCER("manager.tablet.balancer", "org.apache.accumulo.core.spi.balancer.TableLoadBalancer", PropertyType.CLASSNAME, "The balancer class that accumulo will use to make tablet assignment and " diff --git a/core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java b/core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java index 751e3d42a4b..62fee8ac78e 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/AbstractFateStore.java @@ -40,6 +40,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -161,16 +162,21 @@ public FateTxStore reserve(FateId fateId) { EnumSet.of(TStatus.SUBMITTED, TStatus.FAILED_IN_PROGRESS); @Override - public void runnable(AtomicBoolean keepWaiting, Consumer idConsumer) { + public void runnable(Set partitions, BooleanSupplier keepWaiting, + Consumer idConsumer) { + + if (partitions.isEmpty()) { + return; + } AtomicLong seen = new AtomicLong(0); - while (keepWaiting.get() && seen.get() == 0) { + while (keepWaiting.getAsBoolean() && seen.get() == 0) { final long beforeCount = unreservedRunnableCount.getCount(); final boolean beforeDeferredOverflow = deferredOverflow.get(); - try (Stream inProgress = getTransactions(IN_PROGRESS_SET); - Stream other = getTransactions(OTHER_RUNNABLE_SET)) { + try (Stream inProgress = getTransactions(partitions, IN_PROGRESS_SET); + Stream other = getTransactions(partitions, OTHER_RUNNABLE_SET)) { // read the in progress transaction first and then everything else in order to process those // first var transactions = Stream.concat(inProgress, other); @@ -199,6 +205,8 @@ public void runnable(AtomicBoolean keepWaiting, Consumer idConsume if (beforeCount == unreservedRunnableCount.getCount()) { long waitTime = 5000; synchronized (deferred) { + deferred.keySet().removeIf( + fateId -> partitions.stream().noneMatch(partition -> partition.contains(fateId))); if (!deferred.isEmpty()) { waitTime = deferred.values().stream() .mapToLong(countDownTimer -> countDownTimer.timeLeft(TimeUnit.MILLISECONDS)).min() @@ -207,8 +215,7 @@ public void runnable(AtomicBoolean keepWaiting, Consumer idConsume } if (waitTime > 0) { - unreservedRunnableCount.waitFor(count -> count != beforeCount, waitTime, - keepWaiting::get); + unreservedRunnableCount.waitFor(count -> count != beforeCount, waitTime, keepWaiting); } } } @@ -240,9 +247,11 @@ public ReadOnlyFateTxStore read(FateId fateId) { } @Override - public Map getActiveReservations() { - return list().filter(entry -> entry.getFateReservation().isPresent()).collect(Collectors - .toMap(FateIdStatus::getFateId, entry -> entry.getFateReservation().orElseThrow())); + public Map getActiveReservations(Set partitions) { + try (var stream = getTransactions(partitions, EnumSet.allOf(TStatus.class))) { + return stream.filter(entry -> entry.getFateReservation().isPresent()).collect(Collectors + .toMap(FateIdStatus::getFateId, entry -> entry.getFateReservation().orElseThrow())); + } } protected boolean isRunnable(TStatus status) { @@ -289,6 +298,9 @@ protected void verifyLock(ZooUtil.LockID lockID, FateId fateId) { protected abstract Stream getTransactions(EnumSet statuses); + protected abstract Stream getTransactions(Set partitions, + EnumSet statuses); + protected abstract TStatus _getStatus(FateId fateId); protected abstract Optional getKey(FateId fateId); @@ -418,7 +430,7 @@ public interface FateIdGenerator { FateId newRandomId(FateInstanceType instanceType); } - protected void seededTx() { + public void seeded() { unreservedRunnableCount.increment(); } diff --git a/core/src/main/java/org/apache/accumulo/core/fate/Fate.java b/core/src/main/java/org/apache/accumulo/core/fate/Fate.java index eebe1147853..699b98dd368 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/Fate.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/Fate.java @@ -19,12 +19,6 @@ package org.apache.accumulo.core.fate; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.FAILED; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.FAILED_IN_PROGRESS; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.NEW; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUBMITTED; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUCCESSFUL; -import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.UNKNOWN; import static org.apache.accumulo.core.util.threads.ThreadPoolNames.META_DEAD_RESERVATION_CLEANER_POOL; import static org.apache.accumulo.core.util.threads.ThreadPoolNames.USER_DEAD_RESERVATION_CLEANER_POOL; @@ -36,7 +30,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Optional; +import java.util.Objects; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.ExecutorService; @@ -48,22 +42,18 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.fate.FateStore.FateTxStore; -import org.apache.accumulo.core.fate.FateStore.Seeder; -import org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus; import org.apache.accumulo.core.logging.FateLogger; import org.apache.accumulo.core.manager.thrift.TFateOperation; -import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.core.util.threads.ThreadPools; -import org.apache.thrift.TApplicationException; +import org.apache.hadoop.util.Sets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; import com.google.gson.JsonParser; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -73,16 +63,18 @@ */ @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Constructor validation is required for proper initialization") -public class Fate { +public class Fate extends FateClient { // FOLLOW_ON remove extension of FateClient. This + // extenstion was added to keep existing test code + // working. Would be cleaner to not extend and refactor + // all code. - private static final Logger log = LoggerFactory.getLogger(Fate.class); + static final Logger log = LoggerFactory.getLogger(Fate.class); private final FateStore store; private final ScheduledFuture fatePoolsWatcherFuture; private final AtomicInteger needMoreThreadsWarnCount = new AtomicInteger(0); private final ExecutorService deadResCleanerExecutor; - private static final EnumSet FINISHED_STATES = EnumSet.of(FAILED, SUCCESSFUL, UNKNOWN); public static final Duration INITIAL_DELAY = Duration.ofSeconds(3); private static final Duration DEAD_RES_CLEANUP_DELAY = Duration.ofMinutes(3); public static final Duration POOL_WATCHER_DELAY = Duration.ofSeconds(30); @@ -90,6 +82,7 @@ public class Fate { private final AtomicBoolean keepRunning = new AtomicBoolean(true); // Visible for FlakyFate test object protected final Set> fateExecutors = new HashSet<>(); + private Set currentPartitions = Set.of(); public enum TxInfo { FATE_OP, AUTO_CLEAN, EXCEPTION, TX_AGEOFF, RETURN_VALUE @@ -222,8 +215,10 @@ public void run() { fe -> fe.getFateOps().equals(fateOps) && fe.getName().equals(fateExecutorName))) { log.debug("[{}] Adding FateExecutor for {} with {} threads", store.type(), fateOps, poolSize); - fateExecutors.add( - new FateExecutor<>(Fate.this, environment, fateOps, poolSize, fateExecutorName)); + var fateExecutor = + new FateExecutor<>(Fate.this, environment, fateOps, poolSize, fateExecutorName); + fateExecutors.add(fateExecutor); + fateExecutor.setPartitions(currentPartitions); } } } @@ -247,7 +242,11 @@ private class DeadReservationCleaner implements Runnable { @Override public void run() { if (keepRunning.get()) { - store.deleteDeadReservations(); + Set partitions; + synchronized (fateExecutors) { + partitions = currentPartitions; + } + store.deleteDeadReservations(partitions); } } } @@ -262,6 +261,7 @@ public void run() { public Fate(T environment, FateStore store, boolean runDeadResCleaner, Function,String> toLogStrFunc, AccumuloConfiguration conf, ScheduledThreadPoolExecutor genSchedExecutor) { + super(store, toLogStrFunc); this.store = FateLogger.wrap(store, toLogStrFunc, false); fatePoolsWatcherFuture = @@ -382,131 +382,15 @@ public AtomicInteger getNeedMoreThreadsWarnCount() { return needMoreThreadsWarnCount; } - // get a transaction id back to the requester before doing any work - public FateId startTransaction() { - return store.create(); - } - - public Seeder beginSeeding() { - return store.beginSeeding(); - } - - public void seedTransaction(FateOperation fateOp, FateKey fateKey, Repo repo, - boolean autoCleanUp) { - try (var seeder = store.beginSeeding()) { - @SuppressWarnings("unused") - var unused = seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp); - } - } - - // start work in the transaction.. it is safe to call this - // multiple times for a transaction... but it will only seed once - public void seedTransaction(FateOperation fateOp, FateId fateId, Repo repo, - boolean autoCleanUp, String goalMessage) { - log.info("[{}] Seeding {} {} {}", store.type(), fateOp, fateId, goalMessage); - store.seedTransaction(fateOp, fateId, repo, autoCleanUp); - } - - // check on the transaction - public TStatus waitForCompletion(FateId fateId) { - return store.read(fateId).waitForStatusChange(FINISHED_STATES); - } - - /** - * Attempts to cancel a running Fate transaction - * - * @param fateId fate transaction id - * @return true if transaction transitioned to a failed state or already in a completed state, - * false otherwise - */ - public boolean cancel(FateId fateId) { - for (int retries = 0; retries < 5; retries++) { - Optional> optionalTxStore = store.tryReserve(fateId); - if (optionalTxStore.isPresent()) { - var txStore = optionalTxStore.orElseThrow(); - try { - TStatus status = txStore.getStatus(); - log.info("[{}] status is: {}", store.type(), status); - if (status == NEW || status == SUBMITTED) { - txStore.setTransactionInfo(TxInfo.EXCEPTION, new TApplicationException( - TApplicationException.INTERNAL_ERROR, "Fate transaction cancelled by user")); - txStore.setStatus(FAILED_IN_PROGRESS); - log.info( - "[{}] Updated status for {} to FAILED_IN_PROGRESS because it was cancelled by user", - store.type(), fateId); - return true; - } else { - log.info("[{}] {} cancelled by user but already in progress or finished state", - store.type(), fateId); - return false; - } - } finally { - txStore.unreserve(Duration.ZERO); - } - } else { - // reserved, lets retry. - UtilWaitThread.sleep(500); - } - } - log.info("[{}] Unable to reserve transaction {} to cancel it", store.type(), fateId); - return false; - } - - // resource cleanup - public void delete(FateId fateId) { - FateTxStore txStore = store.reserve(fateId); - try { - switch (txStore.getStatus()) { - case NEW: - case SUBMITTED: - case FAILED: - case SUCCESSFUL: - txStore.delete(); - break; - case FAILED_IN_PROGRESS: - case IN_PROGRESS: - throw new IllegalStateException("Can not delete in progress transaction " + fateId); - case UNKNOWN: - // nothing to do, it does not exist - break; + public void seeded(Set partitions) { + synchronized (fateExecutors) { + if (Sets.intersection(currentPartitions, partitions).isEmpty()) { + return; } - } finally { - txStore.unreserve(Duration.ZERO); } - } - public String getReturn(FateId fateId) { - FateTxStore txStore = store.reserve(fateId); - try { - if (txStore.getStatus() != SUCCESSFUL) { - throw new IllegalStateException( - "Tried to get exception when transaction " + fateId + " not in successful state"); - } - return (String) txStore.getTransactionInfo(TxInfo.RETURN_VALUE); - } finally { - txStore.unreserve(Duration.ZERO); - } - } - - // get reportable failures - public Exception getException(FateId fateId) { - FateTxStore txStore = store.reserve(fateId); - try { - if (txStore.getStatus() != FAILED) { - throw new IllegalStateException( - "Tried to get exception when transaction " + fateId + " not in failed state"); - } - return (Exception) txStore.getTransactionInfo(TxInfo.EXCEPTION); - } finally { - txStore.unreserve(Duration.ZERO); - } - } - - /** - * Lists transctions for a given fate key type. - */ - public Stream list(FateKey.FateKeyType type) { - return store.list(type); + log.trace("Notified of seeding for {}", partitions); + store.seeded(); } /** @@ -572,6 +456,27 @@ public void close() { store.close(); } + public Set getPartitions() { + synchronized (fateExecutors) { + return currentPartitions; + } + } + + public Set setPartitions(Set partitions) { + Objects.requireNonNull(partitions); + Preconditions.checkArgument( + partitions.stream().allMatch( + fp -> fp.start().getType() == store.type() && fp.end().getType() == store.type()), + "type mismatch type:%s partitions:%s", store.type(), partitions); + + synchronized (fateExecutors) { + var old = currentPartitions; + currentPartitions = Set.copyOf(partitions); + fateExecutors.forEach(fe -> fe.setPartitions(currentPartitions)); + return old; + } + } + private boolean anyFateExecutorIsAlive() { synchronized (fateExecutors) { return fateExecutors.stream().anyMatch(FateExecutor::isAlive); diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FateClient.java b/core/src/main/java/org/apache/accumulo/core/fate/FateClient.java new file mode 100644 index 00000000000..3e87c3cfb09 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/fate/FateClient.java @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.core.fate; + +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.FAILED; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.FAILED_IN_PROGRESS; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.NEW; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUBMITTED; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUCCESSFUL; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.UNKNOWN; + +import java.time.Duration; +import java.util.EnumSet; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Stream; + +import org.apache.accumulo.core.logging.FateLogger; +import org.apache.accumulo.core.util.UtilWaitThread; +import org.apache.thrift.TApplicationException; + +/** + * Supports initiating and checking status of fate operations. + * + */ +public class FateClient { + + private final FateStore store; + + private static final EnumSet FINISHED_STATES = + EnumSet.of(FAILED, SUCCESSFUL, UNKNOWN); + + private AtomicReference> seedingConsumer = new AtomicReference<>(fid -> {}); + + public FateClient(FateStore store, Function,String> toLogStrFunc) { + this.store = FateLogger.wrap(store, toLogStrFunc, false); + ; + } + + // get a transaction id back to the requester before doing any work + public FateId startTransaction() { + return store.create(); + } + + public FateStore.Seeder beginSeeding() { + var seeder = store.beginSeeding(); + return new FateStore.Seeder() { + @Override + public CompletableFuture> attemptToSeedTransaction(Fate.FateOperation fateOp, + FateKey fateKey, Repo repo, boolean autoCleanUp) { + var cfuture = seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp); + return cfuture.thenApply(optional -> { + optional.ifPresent(seedingConsumer.get()); + return optional; + }); + } + + @Override + public void close() { + seeder.close(); + } + }; + } + + public void seedTransaction(Fate.FateOperation fateOp, FateKey fateKey, Repo repo, + boolean autoCleanUp) { + try (var seeder = store.beginSeeding()) { + seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp); + } + } + + // start work in the transaction.. it is safe to call this + // multiple times for a transaction... but it will only seed once + public void seedTransaction(Fate.FateOperation fateOp, FateId fateId, Repo repo, + boolean autoCleanUp, String goalMessage) { + Fate.log.info("[{}] Seeding {} {} {}", store.type(), fateOp, fateId, goalMessage); + store.seedTransaction(fateOp, fateId, repo, autoCleanUp); + seedingConsumer.get().accept(fateId); + } + + // check on the transaction + public ReadOnlyFateStore.TStatus waitForCompletion(FateId fateId) { + return store.read(fateId).waitForStatusChange(FINISHED_STATES); + } + + /** + * Attempts to cancel a running Fate transaction + * + * @param fateId fate transaction id + * @return true if transaction transitioned to a failed state or already in a completed state, + * false otherwise + */ + public boolean cancel(FateId fateId) { + for (int retries = 0; retries < 5; retries++) { + Optional> optionalTxStore = store.tryReserve(fateId); + if (optionalTxStore.isPresent()) { + var txStore = optionalTxStore.orElseThrow(); + try { + ReadOnlyFateStore.TStatus status = txStore.getStatus(); + Fate.log.info("[{}] status is: {}", store.type(), status); + if (status == NEW || status == SUBMITTED) { + txStore.setTransactionInfo(Fate.TxInfo.EXCEPTION, new TApplicationException( + TApplicationException.INTERNAL_ERROR, "Fate transaction cancelled by user")); + txStore.setStatus(FAILED_IN_PROGRESS); + Fate.log.info( + "[{}] Updated status for {} to FAILED_IN_PROGRESS because it was cancelled by user", + store.type(), fateId); + return true; + } else { + Fate.log.info("[{}] {} cancelled by user but already in progress or finished state", + store.type(), fateId); + return false; + } + } finally { + txStore.unreserve(Duration.ZERO); + } + } else { + // reserved, lets retry. + UtilWaitThread.sleep(500); + } + } + Fate.log.info("[{}] Unable to reserve transaction {} to cancel it", store.type(), fateId); + return false; + } + + // resource cleanup + public void delete(FateId fateId) { + FateStore.FateTxStore txStore = store.reserve(fateId); + try { + switch (txStore.getStatus()) { + case NEW: + case SUBMITTED: + case FAILED: + case SUCCESSFUL: + txStore.delete(); + break; + case FAILED_IN_PROGRESS: + case IN_PROGRESS: + throw new IllegalStateException("Can not delete in progress transaction " + fateId); + case UNKNOWN: + // nothing to do, it does not exist + break; + } + } finally { + txStore.unreserve(Duration.ZERO); + } + } + + public String getReturn(FateId fateId) { + FateStore.FateTxStore txStore = store.reserve(fateId); + try { + if (txStore.getStatus() != SUCCESSFUL) { + throw new IllegalStateException( + "Tried to get exception when transaction " + fateId + " not in successful state"); + } + return (String) txStore.getTransactionInfo(Fate.TxInfo.RETURN_VALUE); + } finally { + txStore.unreserve(Duration.ZERO); + } + } + + // get reportable failures + public Exception getException(FateId fateId) { + FateStore.FateTxStore txStore = store.reserve(fateId); + try { + if (txStore.getStatus() != FAILED) { + throw new IllegalStateException( + "Tried to get exception when transaction " + fateId + " not in failed state"); + } + return (Exception) txStore.getTransactionInfo(Fate.TxInfo.EXCEPTION); + } finally { + txStore.unreserve(Duration.ZERO); + } + } + + /** + * Lists transctions for a given fate key type. + */ + public Stream list(FateKey.FateKeyType type) { + return store.list(type); + } + + public void setSeedingConsumer(Consumer seedingConsumer) { + this.seedingConsumer.set(seedingConsumer); + } +} diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java b/core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java index bbf0bcb81ef..2457095209f 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java @@ -33,6 +33,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; @@ -43,6 +44,8 @@ import java.util.concurrent.TransferQueue; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BooleanSupplier; import org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException; import org.apache.accumulo.core.conf.Property; @@ -81,6 +84,7 @@ public class FateExecutor { private final Set fateOps; private final ConcurrentLinkedQueue idleCountHistory = new ConcurrentLinkedQueue<>(); private final FateExecutorMetrics fateExecutorMetrics; + private final AtomicReference> partitions = new AtomicReference<>(Set.of()); public FateExecutor(Fate fate, T environment, Set fateOps, int poolSize, String name) { @@ -298,6 +302,11 @@ protected ConcurrentLinkedQueue getIdleCountHistory() { return idleCountHistory; } + public void setPartitions(Set partitions) { + Objects.requireNonNull(partitions); + this.partitions.set(Set.copyOf(partitions)); + } + /** * A single thread that finds transactions to work on and queues them up. Do not want each worker * thread going to the store and looking for work as it would place more load on the store. @@ -308,7 +317,12 @@ private class WorkFinder implements Runnable { public void run() { while (fate.getKeepRunning().get() && !isShutdown()) { try { - fate.getStore().runnable(fate.getKeepRunning(), fateIdStatus -> { + var localPartitions = partitions.get(); + // if the set of partitions changes, we should stop looking for work w/ the old set of + // partitions + BooleanSupplier keepRunning = + () -> fate.getKeepRunning().get() && localPartitions == partitions.get(); + fate.getStore().runnable(localPartitions, keepRunning, fateIdStatus -> { // The FateId with the fate operation 'fateOp' is workable by this FateExecutor if // 1) This FateExecutor is assigned to work on 'fateOp' ('fateOp' is in 'fateOps') // 2) The transaction was cancelled while NEW. This is an edge case that needs to be @@ -319,7 +333,7 @@ public void run() { var fateOp = fateIdStatus.getFateOperation().orElse(null); if ((fateOp != null && fateOps.contains(fateOp)) || txCancelledWhileNew(status, fateOp)) { - while (fate.getKeepRunning().get() && !isShutdown()) { + while (keepRunning.getAsBoolean() && !isShutdown()) { try { // The reason for calling transfer instead of queueing is avoid rescanning the // storage layer and adding the same thing over and over. For example if all diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FateExecutorMetrics.java b/core/src/main/java/org/apache/accumulo/core/fate/FateExecutorMetrics.java index 4edc70fe7a8..f9753a4ab6e 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/FateExecutorMetrics.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/FateExecutorMetrics.java @@ -22,14 +22,13 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.accumulo.core.metrics.Metric; -import org.apache.accumulo.core.metrics.MetricsProducer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; -public class FateExecutorMetrics implements MetricsProducer { +public class FateExecutorMetrics { private static final Logger log = LoggerFactory.getLogger(FateExecutorMetrics.class); private final FateInstanceType type; private final String poolName; @@ -49,7 +48,6 @@ protected FateExecutorMetrics(FateInstanceType type, String poolName, this.idleWorkerCount = idleWorkerCount; } - @Override public void registerMetrics(MeterRegistry registry) { // noop if already registered or cleared if (state == State.UNREGISTERED) { diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FatePartition.java b/core/src/main/java/org/apache/accumulo/core/fate/FatePartition.java new file mode 100644 index 00000000000..973c22030d6 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/fate/FatePartition.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.core.fate; + +import java.util.UUID; + +import org.apache.accumulo.core.fate.thrift.TFatePartition; + +public record FatePartition(FateId start, FateId end) { + + public TFatePartition toThrift() { + return new TFatePartition(start.canonical(), end.canonical()); + } + + public static FatePartition from(TFatePartition tfp) { + return new FatePartition(FateId.from(tfp.start), FateId.from(tfp.stop)); + } + + private static final FatePartition ALL_USER = + new FatePartition(FateId.from(FateInstanceType.USER, new UUID(0, 0)), + FateId.from(FateInstanceType.USER, new UUID(-1, -1))); + private static final FatePartition ALL_META = + new FatePartition(FateId.from(FateInstanceType.META, new UUID(0, 0)), + FateId.from(FateInstanceType.META, new UUID(-1, -1))); + + public static FatePartition all(FateInstanceType type) { + return switch (type) { + case META -> ALL_META; + case USER -> ALL_USER; + }; + } + + private static final UUID LAST_UUID = new UUID(-1, -1); + + public boolean isEndInclusive() { + return end.getTxUUID().equals(LAST_UUID); + } + + public boolean contains(FateId fateId) { + if (isEndInclusive()) { + return fateId.compareTo(start) >= 0 && fateId.compareTo(end) <= 0; + } else { + return fateId.compareTo(start) >= 0 && fateId.compareTo(end) < 0; + } + + } +} diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FateStore.java b/core/src/main/java/org/apache/accumulo/core/fate/FateStore.java index e28e7936421..9436cce05bd 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/FateStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/FateStore.java @@ -27,8 +27,10 @@ import java.util.Arrays; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.function.BooleanSupplier; import org.apache.accumulo.core.fate.zookeeper.ZooUtil; import org.apache.hadoop.io.DataInputBuffer; @@ -151,8 +153,8 @@ interface FateTxStore extends ReadOnlyFateTxStore { * longer interact with it. * * @param deferTime time to keep this transaction from being returned by - * {@link #runnable(java.util.concurrent.atomic.AtomicBoolean, java.util.function.Consumer)}. - * Must be non-negative. + * {@link #runnable(Set, BooleanSupplier, java.util.function.Consumer)}. Must be + * non-negative. */ void unreserve(Duration deferTime); } @@ -248,7 +250,7 @@ public int hashCode() { * can no longer be worked on so their reservation should be deleted, so they can be picked up and * worked on again. */ - void deleteDeadReservations(); + void deleteDeadReservations(Set partitions); /** * Attempt to reserve the fate transaction. @@ -268,6 +270,11 @@ public int hashCode() { */ FateTxStore reserve(FateId fateId); + /** + * Notification that something in this store was seeded by another process. + */ + void seeded(); + @Override void close(); } diff --git a/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyFateStore.java b/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyFateStore.java index 263a9b090b9..ad7baae9bcc 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyFateStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyFateStore.java @@ -23,7 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.Set; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.stream.Stream; @@ -155,7 +156,7 @@ interface FateIdStatus { * @return a map of the current active reservations with the keys being the transaction that is * reserved and the value being the value stored to indicate the transaction is reserved. */ - Map getActiveReservations(); + Map getActiveReservations(Set partitions); /** * Finds all fate ops that are (IN_PROGRESS, SUBMITTED, or FAILED_IN_PROGRESS) and unreserved. Ids @@ -163,7 +164,8 @@ interface FateIdStatus { * is found or until the keepWaiting parameter is false. It will return once all runnable ids * found were passed to the consumer. */ - void runnable(AtomicBoolean keepWaiting, Consumer idConsumer); + void runnable(Set partitions, BooleanSupplier keepWaiting, + Consumer idConsumer); /** * Returns true if the deferred map was cleared and if deferred executions are currently disabled diff --git a/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java b/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java index 55300470d7b..158c2ce1aa2 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.SortedMap; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -56,6 +57,7 @@ import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.ReadOnlyRepo; import org.apache.accumulo.core.fate.Repo; import org.apache.accumulo.core.fate.StackOverflowException; @@ -196,7 +198,7 @@ private boolean seedTransaction(Supplier> mutatorFactory, String var status = mutator.tryMutate(); if (status == FateMutator.Status.ACCEPTED) { // signal to the super class that a new fate transaction was seeded and is ready to run - seededTx(); + seeded(); log.trace("Attempt to seed {} returned {}", logId, status); return true; } else if (status == FateMutator.Status.REJECTED) { @@ -255,8 +257,8 @@ public Optional> tryReserve(FateId fateId) { } @Override - public void deleteDeadReservations() { - for (Entry activeRes : getActiveReservations().entrySet()) { + public void deleteDeadReservations(Set partitions) { + for (Entry activeRes : getActiveReservations(partitions).entrySet()) { FateId fateId = activeRes.getKey(); FateReservation reservation = activeRes.getValue(); if (!isLockHeld.test(reservation.getLockID())) { @@ -281,9 +283,21 @@ public void deleteDeadReservations() { @Override protected Stream getTransactions(EnumSet statuses) { + return getTransactions(FatePartition.all(FateInstanceType.USER), statuses); + } + + @Override + protected Stream getTransactions(Set partitions, + EnumSet statuses) { + return partitions.stream().flatMap(p -> getTransactions(p, statuses)); + } + + private Stream getTransactions(FatePartition partition, EnumSet statuses) { try { Scanner scanner = context.createScanner(tableName, Authorizations.EMPTY); - scanner.setRange(new Range()); + var range = new Range(getRowId(partition.start()), true, getRowId(partition.end()), + partition.isEndInclusive()); + scanner.setRange(range); RowFateStatusFilter.configureScanner(scanner, statuses); // columns fetched here must be in/added to TxAdminColumnFamily for locality group benefits TxAdminColumnFamily.STATUS_COLUMN.fetch(scanner); @@ -453,7 +467,7 @@ public void close() { var future = pending.get(fateId).getSecond(); switch (result.getValue()) { case ACCEPTED: - seededTx(); + seeded(); log.trace("Attempt to seed {} returned {}", fateId.canonical(), status); // Complete the future with the fatId and remove from pending future.complete(Optional.of(fateId)); diff --git a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/MetaFateStore.java b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/MetaFateStore.java index f6f67dfef22..a7cf3236af7 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/MetaFateStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/MetaFateStore.java @@ -55,6 +55,7 @@ import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.ReadOnlyRepo; import org.apache.accumulo.core.fate.Repo; import org.apache.accumulo.core.fate.StackOverflowException; @@ -71,6 +72,9 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Suppliers; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -279,8 +283,8 @@ public Optional> tryReserve(FateId fateId) { } @Override - public void deleteDeadReservations() { - for (Map.Entry entry : getActiveReservations().entrySet()) { + public void deleteDeadReservations(Set partitions) { + for (Map.Entry entry : getActiveReservations(partitions).entrySet()) { FateId fateId = entry.getKey(); FateReservation reservation = entry.getValue(); if (isLockHeld.test(reservation.getLockID())) { @@ -616,6 +620,16 @@ public Optional getFateOperation() { } } + @Override + protected Stream getTransactions(Set partitions, + EnumSet statuses) { + + RangeSet rangeSet = TreeRangeSet.create(); + partitions.forEach(partition -> rangeSet.add(Range.closed(partition.start(), partition.end()))); + + return getTransactions(statuses).filter(fis -> rangeSet.contains(fis.getFateId())); + } + @Override public Stream list(FateKey.FateKeyType type) { return getTransactions(EnumSet.allOf(TStatus.class)) diff --git a/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockData.java b/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockData.java index c29879f05c7..9997d75c11c 100644 --- a/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockData.java +++ b/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockData.java @@ -46,6 +46,7 @@ public static enum ThriftService { COORDINATOR, COMPACTOR, FATE, + MANAGER_ASSISTANT, GC, MANAGER, NONE, diff --git a/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockPaths.java b/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockPaths.java index 68c29c485f0..4abe201a61f 100644 --- a/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockPaths.java +++ b/core/src/main/java/org/apache/accumulo/core/lock/ServiceLockPaths.java @@ -77,7 +77,8 @@ private ServiceLockPath(String type) { Preconditions.checkArgument(this.type.equals(Constants.ZGC_LOCK) || this.type.equals(Constants.ZMANAGER_LOCK) || this.type.equals(Constants.ZMONITOR_LOCK) || this.type.equals(Constants.ZTABLE_LOCKS) || this.type.equals(Constants.ZADMIN_LOCK) - || this.type.equals(Constants.ZTEST_LOCK), "Unsupported type: " + type); + || this.type.equals(Constants.ZTEST_LOCK) + || this.type.equals(Constants.ZMANAGER_ASSISTANT_LOCK), "Unsupported type: " + type); // These server types support only one active instance, so they use a lock at // a known path, not the server's address. this.resourceGroup = null; @@ -105,7 +106,8 @@ private ServiceLockPath(String type, ResourceGroupId resourceGroup, HostAndPort this.type = requireNonNull(type); Preconditions.checkArgument( this.type.equals(Constants.ZCOMPACTORS) || this.type.equals(Constants.ZSSERVERS) - || this.type.equals(Constants.ZTSERVERS) || this.type.equals(Constants.ZDEADTSERVERS), + || this.type.equals(Constants.ZTSERVERS) || this.type.equals(Constants.ZDEADTSERVERS) + || this.type.equals(Constants.ZMANAGER_ASSISTANT_LOCK), "Unsupported type: " + type); this.resourceGroup = requireNonNull(resourceGroup); this.server = requireNonNull(server).toString(); @@ -170,6 +172,8 @@ private static String determineServerType(final String path) { return Constants.ZGC_LOCK; } else if (pathStartsWith(path, Constants.ZMANAGER_LOCK)) { return Constants.ZMANAGER_LOCK; + } else if (pathStartsWith(path, Constants.ZMANAGER_ASSISTANT_LOCK)) { + return Constants.ZMANAGER_ASSISTANT_LOCK; } else if (pathStartsWith(path, Constants.ZMONITOR_LOCK)) { return Constants.ZMONITOR_LOCK; } else if (pathStartsWith(path, Constants.ZMINI_LOCK)) { @@ -219,7 +223,7 @@ public static ServiceLockPath parse(Optional serverType, String path) { return switch (type) { case Constants.ZMINI_LOCK -> new ServiceLockPath(type, server); case Constants.ZCOMPACTORS, Constants.ZSSERVERS, Constants.ZTSERVERS, - Constants.ZDEADTSERVERS -> + Constants.ZDEADTSERVERS, Constants.ZMANAGER_ASSISTANT_LOCK -> new ServiceLockPath(type, ResourceGroupId.of(resourceGroup), HostAndPort.fromString(server)); default -> @@ -238,6 +242,11 @@ public ServiceLockPath createManagerPath() { return new ServiceLockPath(Constants.ZMANAGER_LOCK); } + public ServiceLockPath createManagerWorkerPath(ResourceGroupId resourceGroup, + HostAndPort advertiseAddress) { + return new ServiceLockPath(Constants.ZMANAGER_ASSISTANT_LOCK, resourceGroup, advertiseAddress); + } + public ServiceLockPath createMiniPath(String miniUUID) { return new ServiceLockPath(Constants.ZMINI_LOCK, miniUUID); } @@ -287,6 +296,11 @@ public Set getCompactor(ResourceGroupPredicate resourceGroupPre return get(Constants.ZCOMPACTORS, resourceGroupPredicate, address, withLock); } + public Set getManagerWorker(ResourceGroupPredicate resourceGroupPredicate, + AddressSelector address, boolean withLock) { + return get(Constants.ZMANAGER_ASSISTANT_LOCK, resourceGroupPredicate, address, withLock); + } + /** * Note that the ServiceLockPath object returned by this method does not populate the server * attribute. To get the location of the GarbageCollector you will need to parse the lock data at @@ -317,6 +331,11 @@ public ServiceLockPath getManager(boolean withLock) { } } + public Set getAssistantManagers(AddressSelector address, boolean withLock) { + return get(Constants.ZMANAGER_ASSISTANT_LOCK, ResourceGroupPredicate.DEFAULT_RG_ONLY, address, + withLock); + } + /** * Note that the ServiceLockPath object returned by this method does not populate the server * attribute. To get the location of the Monitor you will need to parse the lock data at the @@ -431,7 +450,8 @@ private Set get(final String serverType, } } } else if (serverType.equals(Constants.ZCOMPACTORS) || serverType.equals(Constants.ZSSERVERS) - || serverType.equals(Constants.ZTSERVERS) || serverType.equals(Constants.ZDEADTSERVERS)) { + || serverType.equals(Constants.ZTSERVERS) || serverType.equals(Constants.ZDEADTSERVERS) + || serverType.equals(Constants.ZMANAGER_ASSISTANT_LOCK)) { final List resourceGroups = zooCache.getChildren(typePath); for (final String group : resourceGroups) { if (resourceGroupPredicate.test(ResourceGroupId.of(group))) { diff --git a/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java b/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java index 331401fc6bb..0fa5fec2968 100644 --- a/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java +++ b/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java @@ -23,8 +23,9 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Stream; @@ -34,6 +35,7 @@ import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.FateStore.FateTxStore; import org.apache.accumulo.core.fate.FateStore.Seeder; @@ -113,6 +115,11 @@ public FateTxStore reserve(FateId fateId) { return new LoggingFateTxStore<>(store.reserve(fateId), toLogString, allowForceDel); } + @Override + public void seeded() { + store.seeded(); + } + @Override public Optional> tryReserve(FateId fateId) { return store.tryReserve(fateId) @@ -140,8 +147,9 @@ public Stream list(FateKey.FateKeyType type) { } @Override - public void runnable(AtomicBoolean keepWaiting, Consumer idConsumer) { - store.runnable(keepWaiting, idConsumer); + public void runnable(Set partitions, BooleanSupplier keepWaiting, + Consumer idConsumer) { + store.runnable(partitions, keepWaiting, idConsumer); } @Override @@ -162,8 +170,8 @@ public Seeder beginSeeding() { public boolean seedTransaction(Fate.FateOperation fateOp, FateId fateId, Repo repo, boolean autoCleanUp) { boolean seeded = store.seedTransaction(fateOp, fateId, repo, autoCleanUp); - if (storeLog.isTraceEnabled()) { - storeLog.trace("{} {} {} {}", fateId, seeded ? "seeded" : "unable to seed", + if (storeLog.isDebugEnabled()) { + storeLog.debug("{} {} {} {}", fateId, seeded ? "seeded" : "unable to seed", toLogString.apply(repo), autoCleanUp); } return seeded; @@ -185,13 +193,13 @@ public boolean isDeferredOverflow() { } @Override - public Map getActiveReservations() { - return store.getActiveReservations(); + public Map getActiveReservations(Set partitions) { + return store.getActiveReservations(partitions); } @Override - public void deleteDeadReservations() { - store.deleteDeadReservations(); + public void deleteDeadReservations(Set partitions) { + store.deleteDeadReservations(partitions); } @Override @@ -217,12 +225,12 @@ public CompletableFuture> attemptToSeedTransaction(FateOperatio FateKey fateKey, Repo repo, boolean autoCleanUp) { var future = this.seeder.attemptToSeedTransaction(fateOp, fateKey, repo, autoCleanUp); return future.whenComplete((optional, throwable) -> { - if (storeLog.isTraceEnabled()) { + if (storeLog.isDebugEnabled()) { optional.ifPresentOrElse(fateId -> { - storeLog.trace("{} seeded {} {} {}", fateId, fateKey, toLogString.apply(repo), + storeLog.debug("{} seeded {} {} {}", fateId, fateKey, toLogString.apply(repo), autoCleanUp); }, () -> { - storeLog.trace("Possibly unable to seed {} {} {}", fateKey, toLogString.apply(repo), + storeLog.debug("Possibly unable to seed {} {} {}", fateKey, toLogString.apply(repo), autoCleanUp); }); } diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/clients/FateWorkerServiceThriftClient.java b/core/src/main/java/org/apache/accumulo/core/rpc/clients/FateWorkerServiceThriftClient.java new file mode 100644 index 00000000000..bb4a757c41f --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/rpc/clients/FateWorkerServiceThriftClient.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.core.rpc.clients; + +import org.apache.accumulo.core.fate.thrift.FateWorkerService; + +/** + * Client side object that can be used to interact with services that support scan operations + * against tablets. See TabletScanClientService$Iface for a list of supported operations. + */ +public class FateWorkerServiceThriftClient extends ThriftClientTypes { + FateWorkerServiceThriftClient(String serviceName) { + super(serviceName, new FateWorkerService.Client.Factory()); + } +} diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/clients/ThriftClientTypes.java b/core/src/main/java/org/apache/accumulo/core/rpc/clients/ThriftClientTypes.java index 5b9a5c203d1..7576356f0b9 100644 --- a/core/src/main/java/org/apache/accumulo/core/rpc/clients/ThriftClientTypes.java +++ b/core/src/main/java/org/apache/accumulo/core/rpc/clients/ThriftClientTypes.java @@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.clientImpl.ClientContext; +import org.apache.accumulo.core.fate.thrift.FateWorkerService; import org.apache.thrift.TException; import org.apache.thrift.TServiceClient; import org.apache.thrift.TServiceClientFactory; @@ -61,6 +62,9 @@ public abstract class ThriftClientTypes { public static final ServerProcessServiceThriftClient SERVER_PROCESS = new ServerProcessServiceThriftClient("process"); + public static final ThriftClientTypes FATE_WORKER = + new FateWorkerServiceThriftClient("fateworker"); + /** * execute method with supplied client returning object of type R * diff --git a/core/src/main/scripts/generate-thrift.sh b/core/src/main/scripts/generate-thrift.sh index 1f787d46523..397f042dd7c 100755 --- a/core/src/main/scripts/generate-thrift.sh +++ b/core/src/main/scripts/generate-thrift.sh @@ -32,7 +32,7 @@ [[ -z $REQUIRED_THRIFT_VERSION ]] && REQUIRED_THRIFT_VERSION='0.17.0' [[ -z $INCLUDED_MODULES ]] && INCLUDED_MODULES=() [[ -z $BASE_OUTPUT_PACKAGE ]] && BASE_OUTPUT_PACKAGE='org.apache.accumulo.core' -[[ -z $PACKAGES_TO_GENERATE ]] && PACKAGES_TO_GENERATE=(process gc manager tabletserver securityImpl clientImpl dataImpl compaction tabletingest tablet tabletscan) +[[ -z $PACKAGES_TO_GENERATE ]] && PACKAGES_TO_GENERATE=(process gc manager tabletserver securityImpl clientImpl dataImpl compaction fate tabletingest tablet tabletscan) [[ -z $BUILD_DIR ]] && BUILD_DIR='target' [[ -z $LANGUAGES_TO_GENERATE ]] && LANGUAGES_TO_GENERATE=(java) [[ -z $FINAL_DIR ]] && FINAL_DIR='src/main' diff --git a/core/src/main/spotbugs/exclude-filter.xml b/core/src/main/spotbugs/exclude-filter.xml index cfaac3ea6f0..b8e08762165 100644 --- a/core/src/main/spotbugs/exclude-filter.xml +++ b/core/src/main/spotbugs/exclude-filter.xml @@ -30,6 +30,7 @@ + diff --git a/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/FateWorkerService.java b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/FateWorkerService.java new file mode 100644 index 00000000000..ff22db8c5f9 --- /dev/null +++ b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/FateWorkerService.java @@ -0,0 +1,3778 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * Autogenerated by Thrift Compiler (0.17.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.accumulo.core.fate.thrift; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +public class FateWorkerService { + + public interface Iface { + + public TFatePartitions getPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException; + + public boolean setPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired) throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException; + + public void seeded(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions) throws org.apache.thrift.TException; + + } + + public interface AsyncIface { + + public void getPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void setPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void seeded(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + } + + public static class Client extends org.apache.thrift.TServiceClient implements Iface { + public static class Factory implements org.apache.thrift.TServiceClientFactory { + public Factory() {} + @Override + public Client getClient(org.apache.thrift.protocol.TProtocol prot) { + return new Client(prot); + } + @Override + public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + return new Client(iprot, oprot); + } + } + + public Client(org.apache.thrift.protocol.TProtocol prot) + { + super(prot, prot); + } + + public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + super(iprot, oprot); + } + + @Override + public TFatePartitions getPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException + { + send_getPartitions(tinfo, credentials); + return recv_getPartitions(); + } + + public void send_getPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) throws org.apache.thrift.TException + { + getPartitions_args args = new getPartitions_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + sendBase("getPartitions", args); + } + + public TFatePartitions recv_getPartitions() throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException + { + getPartitions_result result = new getPartitions_result(); + receiveBase(result, "getPartitions"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.sec != null) { + throw result.sec; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getPartitions failed: unknown result"); + } + + @Override + public boolean setPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired) throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException + { + send_setPartitions(tinfo, credentials, updateId, desired); + return recv_setPartitions(); + } + + public void send_setPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired) throws org.apache.thrift.TException + { + setPartitions_args args = new setPartitions_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setUpdateId(updateId); + args.setDesired(desired); + sendBase("setPartitions", args); + } + + public boolean recv_setPartitions() throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException + { + setPartitions_result result = new setPartitions_result(); + receiveBase(result, "setPartitions"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.sec != null) { + throw result.sec; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "setPartitions failed: unknown result"); + } + + @Override + public void seeded(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions) throws org.apache.thrift.TException + { + send_seeded(tinfo, credentials, tpartitions); + recv_seeded(); + } + + public void send_seeded(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions) throws org.apache.thrift.TException + { + seeded_args args = new seeded_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setTpartitions(tpartitions); + sendBase("seeded", args); + } + + public void recv_seeded() throws org.apache.thrift.TException + { + seeded_result result = new seeded_result(); + receiveBase(result, "seeded"); + return; + } + + } + public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { + public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { + private org.apache.thrift.async.TAsyncClientManager clientManager; + private org.apache.thrift.protocol.TProtocolFactory protocolFactory; + public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { + this.clientManager = clientManager; + this.protocolFactory = protocolFactory; + } + @Override + public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { + return new AsyncClient(protocolFactory, clientManager, transport); + } + } + + public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { + super(protocolFactory, clientManager, transport); + } + + @Override + public void getPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getPartitions_call method_call = new getPartitions_call(tinfo, credentials, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getPartitions_call extends org.apache.thrift.async.TAsyncMethodCall { + private org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; + private org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; + public getPartitions_call(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.tinfo = tinfo; + this.credentials = credentials; + } + + @Override + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getPartitions", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getPartitions_args args = new getPartitions_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.write(prot); + prot.writeMessageEnd(); + } + + @Override + public TFatePartitions getResult() throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getPartitions(); + } + } + + @Override + public void setPartitions(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + setPartitions_call method_call = new setPartitions_call(tinfo, credentials, updateId, desired, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class setPartitions_call extends org.apache.thrift.async.TAsyncMethodCall { + private org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; + private org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; + private long updateId; + private java.util.List desired; + public setPartitions_call(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, long updateId, java.util.List desired, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.tinfo = tinfo; + this.credentials = credentials; + this.updateId = updateId; + this.desired = desired; + } + + @Override + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("setPartitions", org.apache.thrift.protocol.TMessageType.CALL, 0)); + setPartitions_args args = new setPartitions_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setUpdateId(updateId); + args.setDesired(desired); + args.write(prot); + prot.writeMessageEnd(); + } + + @Override + public java.lang.Boolean getResult() throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_setPartitions(); + } + } + + @Override + public void seeded(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + seeded_call method_call = new seeded_call(tinfo, credentials, tpartitions, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class seeded_call extends org.apache.thrift.async.TAsyncMethodCall { + private org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; + private org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; + private java.util.List tpartitions; + public seeded_call(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List tpartitions, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.tinfo = tinfo; + this.credentials = credentials; + this.tpartitions = tpartitions; + } + + @Override + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("seeded", org.apache.thrift.protocol.TMessageType.CALL, 0)); + seeded_args args = new seeded_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setTpartitions(tpartitions); + args.write(prot); + prot.writeMessageEnd(); + } + + @Override + public Void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_seeded(); + return null; + } + } + + } + + public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); + public Processor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected Processor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("getPartitions", new getPartitions()); + processMap.put("setPartitions", new setPartitions()); + processMap.put("seeded", new seeded()); + return processMap; + } + + public static class getPartitions extends org.apache.thrift.ProcessFunction { + public getPartitions() { + super("getPartitions"); + } + + @Override + public getPartitions_args getEmptyArgsInstance() { + return new getPartitions_args(); + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + @Override + public getPartitions_result getResult(I iface, getPartitions_args args) throws org.apache.thrift.TException { + getPartitions_result result = new getPartitions_result(); + try { + result.success = iface.getPartitions(args.tinfo, args.credentials); + } catch (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { + result.sec = sec; + } + return result; + } + } + + public static class setPartitions extends org.apache.thrift.ProcessFunction { + public setPartitions() { + super("setPartitions"); + } + + @Override + public setPartitions_args getEmptyArgsInstance() { + return new setPartitions_args(); + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + @Override + public setPartitions_result getResult(I iface, setPartitions_args args) throws org.apache.thrift.TException { + setPartitions_result result = new setPartitions_result(); + try { + result.success = iface.setPartitions(args.tinfo, args.credentials, args.updateId, args.desired); + result.setSuccessIsSet(true); + } catch (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { + result.sec = sec; + } + return result; + } + } + + public static class seeded extends org.apache.thrift.ProcessFunction { + public seeded() { + super("seeded"); + } + + @Override + public seeded_args getEmptyArgsInstance() { + return new seeded_args(); + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + @Override + public seeded_result getResult(I iface, seeded_args args) throws org.apache.thrift.TException { + seeded_result result = new seeded_result(); + iface.seeded(args.tinfo, args.credentials, args.tpartitions); + return result; + } + } + + } + + public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); + public AsyncProcessor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected AsyncProcessor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("getPartitions", new getPartitions()); + processMap.put("setPartitions", new setPartitions()); + processMap.put("seeded", new seeded()); + return processMap; + } + + public static class getPartitions extends org.apache.thrift.AsyncProcessFunction { + public getPartitions() { + super("getPartitions"); + } + + @Override + public getPartitions_args getEmptyArgsInstance() { + return new getPartitions_args(); + } + + @Override + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + @Override + public void onComplete(TFatePartitions o) { + getPartitions_result result = new getPartitions_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + @Override + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + getPartitions_result result = new getPartitions_result(); + if (e instanceof org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) { + result.sec = (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) e; + result.setSecIsSet(true); + msg = result; + } else if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + public void start(I iface, getPartitions_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.getPartitions(args.tinfo, args.credentials,resultHandler); + } + } + + public static class setPartitions extends org.apache.thrift.AsyncProcessFunction { + public setPartitions() { + super("setPartitions"); + } + + @Override + public setPartitions_args getEmptyArgsInstance() { + return new setPartitions_args(); + } + + @Override + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + @Override + public void onComplete(java.lang.Boolean o) { + setPartitions_result result = new setPartitions_result(); + result.success = o; + result.setSuccessIsSet(true); + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + @Override + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + setPartitions_result result = new setPartitions_result(); + if (e instanceof org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) { + result.sec = (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) e; + result.setSecIsSet(true); + msg = result; + } else if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + public void start(I iface, setPartitions_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.setPartitions(args.tinfo, args.credentials, args.updateId, args.desired,resultHandler); + } + } + + public static class seeded extends org.apache.thrift.AsyncProcessFunction { + public seeded() { + super("seeded"); + } + + @Override + public seeded_args getEmptyArgsInstance() { + return new seeded_args(); + } + + @Override + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + @Override + public void onComplete(Void o) { + seeded_result result = new seeded_result(); + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + @Override + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + seeded_result result = new seeded_result(); + if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + public void start(I iface, seeded_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.seeded(args.tinfo, args.credentials, args.tpartitions,resultHandler); + } + } + + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class getPartitions_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getPartitions_args"); + + private static final org.apache.thrift.protocol.TField TINFO_FIELD_DESC = new org.apache.thrift.protocol.TField("tinfo", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getPartitions_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getPartitions_argsTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TINFO((short)1, "tinfo"), + CREDENTIALS((short)2, "credentials"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TINFO + return TINFO; + case 2: // CREDENTIALS + return CREDENTIALS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TINFO, new org.apache.thrift.meta_data.FieldMetaData("tinfo", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.TInfo.class))); + tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.securityImpl.thrift.TCredentials.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getPartitions_args.class, metaDataMap); + } + + public getPartitions_args() { + } + + public getPartitions_args( + org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, + org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) + { + this(); + this.tinfo = tinfo; + this.credentials = credentials; + } + + /** + * Performs a deep copy on other. + */ + public getPartitions_args(getPartitions_args other) { + if (other.isSetTinfo()) { + this.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(other.tinfo); + } + if (other.isSetCredentials()) { + this.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(other.credentials); + } + } + + @Override + public getPartitions_args deepCopy() { + return new getPartitions_args(this); + } + + @Override + public void clear() { + this.tinfo = null; + this.credentials = null; + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.TInfo getTinfo() { + return this.tinfo; + } + + public getPartitions_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { + this.tinfo = tinfo; + return this; + } + + public void unsetTinfo() { + this.tinfo = null; + } + + /** Returns true if field tinfo is set (has been assigned a value) and false otherwise */ + public boolean isSetTinfo() { + return this.tinfo != null; + } + + public void setTinfoIsSet(boolean value) { + if (!value) { + this.tinfo = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.securityImpl.thrift.TCredentials getCredentials() { + return this.credentials; + } + + public getPartitions_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { + this.credentials = credentials; + return this; + } + + public void unsetCredentials() { + this.credentials = null; + } + + /** Returns true if field credentials is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentials() { + return this.credentials != null; + } + + public void setCredentialsIsSet(boolean value) { + if (!value) { + this.credentials = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case TINFO: + if (value == null) { + unsetTinfo(); + } else { + setTinfo((org.apache.accumulo.core.clientImpl.thrift.TInfo)value); + } + break; + + case CREDENTIALS: + if (value == null) { + unsetCredentials(); + } else { + setCredentials((org.apache.accumulo.core.securityImpl.thrift.TCredentials)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case TINFO: + return getTinfo(); + + case CREDENTIALS: + return getCredentials(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case TINFO: + return isSetTinfo(); + case CREDENTIALS: + return isSetCredentials(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getPartitions_args) + return this.equals((getPartitions_args)that); + return false; + } + + public boolean equals(getPartitions_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_tinfo = true && this.isSetTinfo(); + boolean that_present_tinfo = true && that.isSetTinfo(); + if (this_present_tinfo || that_present_tinfo) { + if (!(this_present_tinfo && that_present_tinfo)) + return false; + if (!this.tinfo.equals(that.tinfo)) + return false; + } + + boolean this_present_credentials = true && this.isSetCredentials(); + boolean that_present_credentials = true && that.isSetCredentials(); + if (this_present_credentials || that_present_credentials) { + if (!(this_present_credentials && that_present_credentials)) + return false; + if (!this.credentials.equals(that.credentials)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTinfo()) ? 131071 : 524287); + if (isSetTinfo()) + hashCode = hashCode * 8191 + tinfo.hashCode(); + + hashCode = hashCode * 8191 + ((isSetCredentials()) ? 131071 : 524287); + if (isSetCredentials()) + hashCode = hashCode * 8191 + credentials.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getPartitions_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetTinfo(), other.isSetTinfo()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTinfo()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tinfo, other.tinfo); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetCredentials(), other.isSetCredentials()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentials()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentials, other.credentials); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getPartitions_args("); + boolean first = true; + + sb.append("tinfo:"); + if (this.tinfo == null) { + sb.append("null"); + } else { + sb.append(this.tinfo); + } + first = false; + if (!first) sb.append(", "); + sb.append("credentials:"); + if (this.credentials == null) { + sb.append("null"); + } else { + sb.append(this.credentials); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (tinfo != null) { + tinfo.validate(); + } + if (credentials != null) { + credentials.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getPartitions_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getPartitions_argsStandardScheme getScheme() { + return new getPartitions_argsStandardScheme(); + } + } + + private static class getPartitions_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TINFO + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // CREDENTIALS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getPartitions_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.tinfo != null) { + oprot.writeFieldBegin(TINFO_FIELD_DESC); + struct.tinfo.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.credentials != null) { + oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); + struct.credentials.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getPartitions_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getPartitions_argsTupleScheme getScheme() { + return new getPartitions_argsTupleScheme(); + } + } + + private static class getPartitions_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetTinfo()) { + optionals.set(0); + } + if (struct.isSetCredentials()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetTinfo()) { + struct.tinfo.write(oprot); + } + if (struct.isSetCredentials()) { + struct.credentials.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } + if (incoming.get(1)) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class getPartitions_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getPartitions_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + private static final org.apache.thrift.protocol.TField SEC_FIELD_DESC = new org.apache.thrift.protocol.TField("sec", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getPartitions_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getPartitions_resultTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable TFatePartitions success; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + SEC((short)1, "sec"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // SEC + return SEC; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TFatePartitions.class))); + tmpMap.put(_Fields.SEC, new org.apache.thrift.meta_data.FieldMetaData("sec", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getPartitions_result.class, metaDataMap); + } + + public getPartitions_result() { + } + + public getPartitions_result( + TFatePartitions success, + org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) + { + this(); + this.success = success; + this.sec = sec; + } + + /** + * Performs a deep copy on other. + */ + public getPartitions_result(getPartitions_result other) { + if (other.isSetSuccess()) { + this.success = new TFatePartitions(other.success); + } + if (other.isSetSec()) { + this.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(other.sec); + } + } + + @Override + public getPartitions_result deepCopy() { + return new getPartitions_result(this); + } + + @Override + public void clear() { + this.success = null; + this.sec = null; + } + + @org.apache.thrift.annotation.Nullable + public TFatePartitions getSuccess() { + return this.success; + } + + public getPartitions_result setSuccess(@org.apache.thrift.annotation.Nullable TFatePartitions success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException getSec() { + return this.sec; + } + + public getPartitions_result setSec(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { + this.sec = sec; + return this; + } + + public void unsetSec() { + this.sec = null; + } + + /** Returns true if field sec is set (has been assigned a value) and false otherwise */ + public boolean isSetSec() { + return this.sec != null; + } + + public void setSecIsSet(boolean value) { + if (!value) { + this.sec = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TFatePartitions)value); + } + break; + + case SEC: + if (value == null) { + unsetSec(); + } else { + setSec((org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case SEC: + return getSec(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case SEC: + return isSetSec(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getPartitions_result) + return this.equals((getPartitions_result)that); + return false; + } + + public boolean equals(getPartitions_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_sec = true && this.isSetSec(); + boolean that_present_sec = true && that.isSetSec(); + if (this_present_sec || that_present_sec) { + if (!(this_present_sec && that_present_sec)) + return false; + if (!this.sec.equals(that.sec)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + hashCode = hashCode * 8191 + ((isSetSec()) ? 131071 : 524287); + if (isSetSec()) + hashCode = hashCode * 8191 + sec.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getPartitions_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetSec(), other.isSetSec()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSec()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sec, other.sec); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getPartitions_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("sec:"); + if (this.sec == null) { + sb.append("null"); + } else { + sb.append(this.sec); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getPartitions_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getPartitions_resultStandardScheme getScheme() { + return new getPartitions_resultStandardScheme(); + } + } + + private static class getPartitions_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new TFatePartitions(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // SEC + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getPartitions_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.sec != null) { + oprot.writeFieldBegin(SEC_FIELD_DESC); + struct.sec.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getPartitions_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getPartitions_resultTupleScheme getScheme() { + return new getPartitions_resultTupleScheme(); + } + } + + private static class getPartitions_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetSec()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + if (struct.isSetSec()) { + struct.sec.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.success = new TFatePartitions(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class setPartitions_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setPartitions_args"); + + private static final org.apache.thrift.protocol.TField TINFO_FIELD_DESC = new org.apache.thrift.protocol.TField("tinfo", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField UPDATE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("updateId", org.apache.thrift.protocol.TType.I64, (short)3); + private static final org.apache.thrift.protocol.TField DESIRED_FIELD_DESC = new org.apache.thrift.protocol.TField("desired", org.apache.thrift.protocol.TType.LIST, (short)4); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setPartitions_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setPartitions_argsTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; // required + public long updateId; // required + public @org.apache.thrift.annotation.Nullable java.util.List desired; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TINFO((short)1, "tinfo"), + CREDENTIALS((short)2, "credentials"), + UPDATE_ID((short)3, "updateId"), + DESIRED((short)4, "desired"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TINFO + return TINFO; + case 2: // CREDENTIALS + return CREDENTIALS; + case 3: // UPDATE_ID + return UPDATE_ID; + case 4: // DESIRED + return DESIRED; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __UPDATEID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TINFO, new org.apache.thrift.meta_data.FieldMetaData("tinfo", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.TInfo.class))); + tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.securityImpl.thrift.TCredentials.class))); + tmpMap.put(_Fields.UPDATE_ID, new org.apache.thrift.meta_data.FieldMetaData("updateId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.DESIRED, new org.apache.thrift.meta_data.FieldMetaData("desired", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TFatePartition.class)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setPartitions_args.class, metaDataMap); + } + + public setPartitions_args() { + } + + public setPartitions_args( + org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, + org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, + long updateId, + java.util.List desired) + { + this(); + this.tinfo = tinfo; + this.credentials = credentials; + this.updateId = updateId; + setUpdateIdIsSet(true); + this.desired = desired; + } + + /** + * Performs a deep copy on other. + */ + public setPartitions_args(setPartitions_args other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetTinfo()) { + this.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(other.tinfo); + } + if (other.isSetCredentials()) { + this.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(other.credentials); + } + this.updateId = other.updateId; + if (other.isSetDesired()) { + java.util.List __this__desired = new java.util.ArrayList(other.desired.size()); + for (TFatePartition other_element : other.desired) { + __this__desired.add(new TFatePartition(other_element)); + } + this.desired = __this__desired; + } + } + + @Override + public setPartitions_args deepCopy() { + return new setPartitions_args(this); + } + + @Override + public void clear() { + this.tinfo = null; + this.credentials = null; + setUpdateIdIsSet(false); + this.updateId = 0; + this.desired = null; + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.TInfo getTinfo() { + return this.tinfo; + } + + public setPartitions_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { + this.tinfo = tinfo; + return this; + } + + public void unsetTinfo() { + this.tinfo = null; + } + + /** Returns true if field tinfo is set (has been assigned a value) and false otherwise */ + public boolean isSetTinfo() { + return this.tinfo != null; + } + + public void setTinfoIsSet(boolean value) { + if (!value) { + this.tinfo = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.securityImpl.thrift.TCredentials getCredentials() { + return this.credentials; + } + + public setPartitions_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { + this.credentials = credentials; + return this; + } + + public void unsetCredentials() { + this.credentials = null; + } + + /** Returns true if field credentials is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentials() { + return this.credentials != null; + } + + public void setCredentialsIsSet(boolean value) { + if (!value) { + this.credentials = null; + } + } + + public long getUpdateId() { + return this.updateId; + } + + public setPartitions_args setUpdateId(long updateId) { + this.updateId = updateId; + setUpdateIdIsSet(true); + return this; + } + + public void unsetUpdateId() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEID_ISSET_ID); + } + + /** Returns true if field updateId is set (has been assigned a value) and false otherwise */ + public boolean isSetUpdateId() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEID_ISSET_ID); + } + + public void setUpdateIdIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEID_ISSET_ID, value); + } + + public int getDesiredSize() { + return (this.desired == null) ? 0 : this.desired.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getDesiredIterator() { + return (this.desired == null) ? null : this.desired.iterator(); + } + + public void addToDesired(TFatePartition elem) { + if (this.desired == null) { + this.desired = new java.util.ArrayList(); + } + this.desired.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getDesired() { + return this.desired; + } + + public setPartitions_args setDesired(@org.apache.thrift.annotation.Nullable java.util.List desired) { + this.desired = desired; + return this; + } + + public void unsetDesired() { + this.desired = null; + } + + /** Returns true if field desired is set (has been assigned a value) and false otherwise */ + public boolean isSetDesired() { + return this.desired != null; + } + + public void setDesiredIsSet(boolean value) { + if (!value) { + this.desired = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case TINFO: + if (value == null) { + unsetTinfo(); + } else { + setTinfo((org.apache.accumulo.core.clientImpl.thrift.TInfo)value); + } + break; + + case CREDENTIALS: + if (value == null) { + unsetCredentials(); + } else { + setCredentials((org.apache.accumulo.core.securityImpl.thrift.TCredentials)value); + } + break; + + case UPDATE_ID: + if (value == null) { + unsetUpdateId(); + } else { + setUpdateId((java.lang.Long)value); + } + break; + + case DESIRED: + if (value == null) { + unsetDesired(); + } else { + setDesired((java.util.List)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case TINFO: + return getTinfo(); + + case CREDENTIALS: + return getCredentials(); + + case UPDATE_ID: + return getUpdateId(); + + case DESIRED: + return getDesired(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case TINFO: + return isSetTinfo(); + case CREDENTIALS: + return isSetCredentials(); + case UPDATE_ID: + return isSetUpdateId(); + case DESIRED: + return isSetDesired(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof setPartitions_args) + return this.equals((setPartitions_args)that); + return false; + } + + public boolean equals(setPartitions_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_tinfo = true && this.isSetTinfo(); + boolean that_present_tinfo = true && that.isSetTinfo(); + if (this_present_tinfo || that_present_tinfo) { + if (!(this_present_tinfo && that_present_tinfo)) + return false; + if (!this.tinfo.equals(that.tinfo)) + return false; + } + + boolean this_present_credentials = true && this.isSetCredentials(); + boolean that_present_credentials = true && that.isSetCredentials(); + if (this_present_credentials || that_present_credentials) { + if (!(this_present_credentials && that_present_credentials)) + return false; + if (!this.credentials.equals(that.credentials)) + return false; + } + + boolean this_present_updateId = true; + boolean that_present_updateId = true; + if (this_present_updateId || that_present_updateId) { + if (!(this_present_updateId && that_present_updateId)) + return false; + if (this.updateId != that.updateId) + return false; + } + + boolean this_present_desired = true && this.isSetDesired(); + boolean that_present_desired = true && that.isSetDesired(); + if (this_present_desired || that_present_desired) { + if (!(this_present_desired && that_present_desired)) + return false; + if (!this.desired.equals(that.desired)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTinfo()) ? 131071 : 524287); + if (isSetTinfo()) + hashCode = hashCode * 8191 + tinfo.hashCode(); + + hashCode = hashCode * 8191 + ((isSetCredentials()) ? 131071 : 524287); + if (isSetCredentials()) + hashCode = hashCode * 8191 + credentials.hashCode(); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updateId); + + hashCode = hashCode * 8191 + ((isSetDesired()) ? 131071 : 524287); + if (isSetDesired()) + hashCode = hashCode * 8191 + desired.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(setPartitions_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetTinfo(), other.isSetTinfo()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTinfo()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tinfo, other.tinfo); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetCredentials(), other.isSetCredentials()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentials()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentials, other.credentials); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetUpdateId(), other.isSetUpdateId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUpdateId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updateId, other.updateId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetDesired(), other.isSetDesired()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDesired()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.desired, other.desired); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("setPartitions_args("); + boolean first = true; + + sb.append("tinfo:"); + if (this.tinfo == null) { + sb.append("null"); + } else { + sb.append(this.tinfo); + } + first = false; + if (!first) sb.append(", "); + sb.append("credentials:"); + if (this.credentials == null) { + sb.append("null"); + } else { + sb.append(this.credentials); + } + first = false; + if (!first) sb.append(", "); + sb.append("updateId:"); + sb.append(this.updateId); + first = false; + if (!first) sb.append(", "); + sb.append("desired:"); + if (this.desired == null) { + sb.append("null"); + } else { + sb.append(this.desired); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (tinfo != null) { + tinfo.validate(); + } + if (credentials != null) { + credentials.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class setPartitions_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public setPartitions_argsStandardScheme getScheme() { + return new setPartitions_argsStandardScheme(); + } + } + + private static class setPartitions_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, setPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TINFO + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // CREDENTIALS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // UPDATE_ID + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.updateId = iprot.readI64(); + struct.setUpdateIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // DESIRED + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); + struct.desired = new java.util.ArrayList(_list8.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem9; + for (int _i10 = 0; _i10 < _list8.size; ++_i10) + { + _elem9 = new TFatePartition(); + _elem9.read(iprot); + struct.desired.add(_elem9); + } + iprot.readListEnd(); + } + struct.setDesiredIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, setPartitions_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.tinfo != null) { + oprot.writeFieldBegin(TINFO_FIELD_DESC); + struct.tinfo.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.credentials != null) { + oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); + struct.credentials.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(UPDATE_ID_FIELD_DESC); + oprot.writeI64(struct.updateId); + oprot.writeFieldEnd(); + if (struct.desired != null) { + oprot.writeFieldBegin(DESIRED_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.desired.size())); + for (TFatePartition _iter11 : struct.desired) + { + _iter11.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class setPartitions_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public setPartitions_argsTupleScheme getScheme() { + return new setPartitions_argsTupleScheme(); + } + } + + private static class setPartitions_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, setPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetTinfo()) { + optionals.set(0); + } + if (struct.isSetCredentials()) { + optionals.set(1); + } + if (struct.isSetUpdateId()) { + optionals.set(2); + } + if (struct.isSetDesired()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); + if (struct.isSetTinfo()) { + struct.tinfo.write(oprot); + } + if (struct.isSetCredentials()) { + struct.credentials.write(oprot); + } + if (struct.isSetUpdateId()) { + oprot.writeI64(struct.updateId); + } + if (struct.isSetDesired()) { + { + oprot.writeI32(struct.desired.size()); + for (TFatePartition _iter12 : struct.desired) + { + _iter12.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, setPartitions_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(4); + if (incoming.get(0)) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } + if (incoming.get(1)) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } + if (incoming.get(2)) { + struct.updateId = iprot.readI64(); + struct.setUpdateIdIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.thrift.protocol.TList _list13 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.desired = new java.util.ArrayList(_list13.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem14; + for (int _i15 = 0; _i15 < _list13.size; ++_i15) + { + _elem14 = new TFatePartition(); + _elem14.read(iprot); + struct.desired.add(_elem14); + } + } + struct.setDesiredIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class setPartitions_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setPartitions_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); + private static final org.apache.thrift.protocol.TField SEC_FIELD_DESC = new org.apache.thrift.protocol.TField("sec", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setPartitions_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setPartitions_resultTupleSchemeFactory(); + + public boolean success; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + SEC((short)1, "sec"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // SEC + return SEC; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SUCCESS_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.SEC, new org.apache.thrift.meta_data.FieldMetaData("sec", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setPartitions_result.class, metaDataMap); + } + + public setPartitions_result() { + } + + public setPartitions_result( + boolean success, + org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) + { + this(); + this.success = success; + setSuccessIsSet(true); + this.sec = sec; + } + + /** + * Performs a deep copy on other. + */ + public setPartitions_result(setPartitions_result other) { + __isset_bitfield = other.__isset_bitfield; + this.success = other.success; + if (other.isSetSec()) { + this.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(other.sec); + } + } + + @Override + public setPartitions_result deepCopy() { + return new setPartitions_result(this); + } + + @Override + public void clear() { + setSuccessIsSet(false); + this.success = false; + this.sec = null; + } + + public boolean isSuccess() { + return this.success; + } + + public setPartitions_result setSuccess(boolean success) { + this.success = success; + setSuccessIsSet(true); + return this; + } + + public void unsetSuccess() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + public void setSuccessIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException getSec() { + return this.sec; + } + + public setPartitions_result setSec(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { + this.sec = sec; + return this; + } + + public void unsetSec() { + this.sec = null; + } + + /** Returns true if field sec is set (has been assigned a value) and false otherwise */ + public boolean isSetSec() { + return this.sec != null; + } + + public void setSecIsSet(boolean value) { + if (!value) { + this.sec = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((java.lang.Boolean)value); + } + break; + + case SEC: + if (value == null) { + unsetSec(); + } else { + setSec((org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return isSuccess(); + + case SEC: + return getSec(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case SEC: + return isSetSec(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof setPartitions_result) + return this.equals((setPartitions_result)that); + return false; + } + + public boolean equals(setPartitions_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true; + boolean that_present_success = true; + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (this.success != that.success) + return false; + } + + boolean this_present_sec = true && this.isSetSec(); + boolean that_present_sec = true && that.isSetSec(); + if (this_present_sec || that_present_sec) { + if (!(this_present_sec && that_present_sec)) + return false; + if (!this.sec.equals(that.sec)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((success) ? 131071 : 524287); + + hashCode = hashCode * 8191 + ((isSetSec()) ? 131071 : 524287); + if (isSetSec()) + hashCode = hashCode * 8191 + sec.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(setPartitions_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetSec(), other.isSetSec()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSec()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sec, other.sec); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("setPartitions_result("); + boolean first = true; + + sb.append("success:"); + sb.append(this.success); + first = false; + if (!first) sb.append(", "); + sb.append("sec:"); + if (this.sec == null) { + sb.append("null"); + } else { + sb.append(this.sec); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class setPartitions_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public setPartitions_resultStandardScheme getScheme() { + return new setPartitions_resultStandardScheme(); + } + } + + private static class setPartitions_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, setPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.success = iprot.readBool(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // SEC + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, setPartitions_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeBool(struct.success); + oprot.writeFieldEnd(); + } + if (struct.sec != null) { + oprot.writeFieldBegin(SEC_FIELD_DESC); + struct.sec.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class setPartitions_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public setPartitions_resultTupleScheme getScheme() { + return new setPartitions_resultTupleScheme(); + } + } + + private static class setPartitions_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, setPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetSec()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSuccess()) { + oprot.writeBool(struct.success); + } + if (struct.isSetSec()) { + struct.sec.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, setPartitions_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.success = iprot.readBool(); + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class seeded_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("seeded_args"); + + private static final org.apache.thrift.protocol.TField TINFO_FIELD_DESC = new org.apache.thrift.protocol.TField("tinfo", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField TPARTITIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("tpartitions", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new seeded_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new seeded_argsTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; // required + public @org.apache.thrift.annotation.Nullable java.util.List tpartitions; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TINFO((short)1, "tinfo"), + CREDENTIALS((short)2, "credentials"), + TPARTITIONS((short)3, "tpartitions"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TINFO + return TINFO; + case 2: // CREDENTIALS + return CREDENTIALS; + case 3: // TPARTITIONS + return TPARTITIONS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TINFO, new org.apache.thrift.meta_data.FieldMetaData("tinfo", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.TInfo.class))); + tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.securityImpl.thrift.TCredentials.class))); + tmpMap.put(_Fields.TPARTITIONS, new org.apache.thrift.meta_data.FieldMetaData("tpartitions", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TFatePartition.class)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(seeded_args.class, metaDataMap); + } + + public seeded_args() { + } + + public seeded_args( + org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, + org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, + java.util.List tpartitions) + { + this(); + this.tinfo = tinfo; + this.credentials = credentials; + this.tpartitions = tpartitions; + } + + /** + * Performs a deep copy on other. + */ + public seeded_args(seeded_args other) { + if (other.isSetTinfo()) { + this.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(other.tinfo); + } + if (other.isSetCredentials()) { + this.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(other.credentials); + } + if (other.isSetTpartitions()) { + java.util.List __this__tpartitions = new java.util.ArrayList(other.tpartitions.size()); + for (TFatePartition other_element : other.tpartitions) { + __this__tpartitions.add(new TFatePartition(other_element)); + } + this.tpartitions = __this__tpartitions; + } + } + + @Override + public seeded_args deepCopy() { + return new seeded_args(this); + } + + @Override + public void clear() { + this.tinfo = null; + this.credentials = null; + this.tpartitions = null; + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.TInfo getTinfo() { + return this.tinfo; + } + + public seeded_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { + this.tinfo = tinfo; + return this; + } + + public void unsetTinfo() { + this.tinfo = null; + } + + /** Returns true if field tinfo is set (has been assigned a value) and false otherwise */ + public boolean isSetTinfo() { + return this.tinfo != null; + } + + public void setTinfoIsSet(boolean value) { + if (!value) { + this.tinfo = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.securityImpl.thrift.TCredentials getCredentials() { + return this.credentials; + } + + public seeded_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { + this.credentials = credentials; + return this; + } + + public void unsetCredentials() { + this.credentials = null; + } + + /** Returns true if field credentials is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentials() { + return this.credentials != null; + } + + public void setCredentialsIsSet(boolean value) { + if (!value) { + this.credentials = null; + } + } + + public int getTpartitionsSize() { + return (this.tpartitions == null) ? 0 : this.tpartitions.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getTpartitionsIterator() { + return (this.tpartitions == null) ? null : this.tpartitions.iterator(); + } + + public void addToTpartitions(TFatePartition elem) { + if (this.tpartitions == null) { + this.tpartitions = new java.util.ArrayList(); + } + this.tpartitions.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getTpartitions() { + return this.tpartitions; + } + + public seeded_args setTpartitions(@org.apache.thrift.annotation.Nullable java.util.List tpartitions) { + this.tpartitions = tpartitions; + return this; + } + + public void unsetTpartitions() { + this.tpartitions = null; + } + + /** Returns true if field tpartitions is set (has been assigned a value) and false otherwise */ + public boolean isSetTpartitions() { + return this.tpartitions != null; + } + + public void setTpartitionsIsSet(boolean value) { + if (!value) { + this.tpartitions = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case TINFO: + if (value == null) { + unsetTinfo(); + } else { + setTinfo((org.apache.accumulo.core.clientImpl.thrift.TInfo)value); + } + break; + + case CREDENTIALS: + if (value == null) { + unsetCredentials(); + } else { + setCredentials((org.apache.accumulo.core.securityImpl.thrift.TCredentials)value); + } + break; + + case TPARTITIONS: + if (value == null) { + unsetTpartitions(); + } else { + setTpartitions((java.util.List)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case TINFO: + return getTinfo(); + + case CREDENTIALS: + return getCredentials(); + + case TPARTITIONS: + return getTpartitions(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case TINFO: + return isSetTinfo(); + case CREDENTIALS: + return isSetCredentials(); + case TPARTITIONS: + return isSetTpartitions(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof seeded_args) + return this.equals((seeded_args)that); + return false; + } + + public boolean equals(seeded_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_tinfo = true && this.isSetTinfo(); + boolean that_present_tinfo = true && that.isSetTinfo(); + if (this_present_tinfo || that_present_tinfo) { + if (!(this_present_tinfo && that_present_tinfo)) + return false; + if (!this.tinfo.equals(that.tinfo)) + return false; + } + + boolean this_present_credentials = true && this.isSetCredentials(); + boolean that_present_credentials = true && that.isSetCredentials(); + if (this_present_credentials || that_present_credentials) { + if (!(this_present_credentials && that_present_credentials)) + return false; + if (!this.credentials.equals(that.credentials)) + return false; + } + + boolean this_present_tpartitions = true && this.isSetTpartitions(); + boolean that_present_tpartitions = true && that.isSetTpartitions(); + if (this_present_tpartitions || that_present_tpartitions) { + if (!(this_present_tpartitions && that_present_tpartitions)) + return false; + if (!this.tpartitions.equals(that.tpartitions)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTinfo()) ? 131071 : 524287); + if (isSetTinfo()) + hashCode = hashCode * 8191 + tinfo.hashCode(); + + hashCode = hashCode * 8191 + ((isSetCredentials()) ? 131071 : 524287); + if (isSetCredentials()) + hashCode = hashCode * 8191 + credentials.hashCode(); + + hashCode = hashCode * 8191 + ((isSetTpartitions()) ? 131071 : 524287); + if (isSetTpartitions()) + hashCode = hashCode * 8191 + tpartitions.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(seeded_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetTinfo(), other.isSetTinfo()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTinfo()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tinfo, other.tinfo); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetCredentials(), other.isSetCredentials()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentials()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentials, other.credentials); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetTpartitions(), other.isSetTpartitions()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTpartitions()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tpartitions, other.tpartitions); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("seeded_args("); + boolean first = true; + + sb.append("tinfo:"); + if (this.tinfo == null) { + sb.append("null"); + } else { + sb.append(this.tinfo); + } + first = false; + if (!first) sb.append(", "); + sb.append("credentials:"); + if (this.credentials == null) { + sb.append("null"); + } else { + sb.append(this.credentials); + } + first = false; + if (!first) sb.append(", "); + sb.append("tpartitions:"); + if (this.tpartitions == null) { + sb.append("null"); + } else { + sb.append(this.tpartitions); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (tinfo != null) { + tinfo.validate(); + } + if (credentials != null) { + credentials.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class seeded_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public seeded_argsStandardScheme getScheme() { + return new seeded_argsStandardScheme(); + } + } + + private static class seeded_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, seeded_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TINFO + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // CREDENTIALS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // TPARTITIONS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); + struct.tpartitions = new java.util.ArrayList(_list16.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem17; + for (int _i18 = 0; _i18 < _list16.size; ++_i18) + { + _elem17 = new TFatePartition(); + _elem17.read(iprot); + struct.tpartitions.add(_elem17); + } + iprot.readListEnd(); + } + struct.setTpartitionsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, seeded_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.tinfo != null) { + oprot.writeFieldBegin(TINFO_FIELD_DESC); + struct.tinfo.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.credentials != null) { + oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); + struct.credentials.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.tpartitions != null) { + oprot.writeFieldBegin(TPARTITIONS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.tpartitions.size())); + for (TFatePartition _iter19 : struct.tpartitions) + { + _iter19.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class seeded_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public seeded_argsTupleScheme getScheme() { + return new seeded_argsTupleScheme(); + } + } + + private static class seeded_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, seeded_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetTinfo()) { + optionals.set(0); + } + if (struct.isSetCredentials()) { + optionals.set(1); + } + if (struct.isSetTpartitions()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetTinfo()) { + struct.tinfo.write(oprot); + } + if (struct.isSetCredentials()) { + struct.credentials.write(oprot); + } + if (struct.isSetTpartitions()) { + { + oprot.writeI32(struct.tpartitions.size()); + for (TFatePartition _iter20 : struct.tpartitions) + { + _iter20.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, seeded_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } + if (incoming.get(1)) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list21 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.tpartitions = new java.util.ArrayList(_list21.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem22; + for (int _i23 = 0; _i23 < _list21.size; ++_i23) + { + _elem22 = new TFatePartition(); + _elem22.read(iprot); + struct.tpartitions.add(_elem22); + } + } + struct.setTpartitionsIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class seeded_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("seeded_result"); + + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new seeded_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new seeded_resultTupleSchemeFactory(); + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(seeded_result.class, metaDataMap); + } + + public seeded_result() { + } + + /** + * Performs a deep copy on other. + */ + public seeded_result(seeded_result other) { + } + + @Override + public seeded_result deepCopy() { + return new seeded_result(this); + } + + @Override + public void clear() { + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof seeded_result) + return this.equals((seeded_result)that); + return false; + } + + public boolean equals(seeded_result that) { + if (that == null) + return false; + if (this == that) + return true; + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + return hashCode; + } + + @Override + public int compareTo(seeded_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("seeded_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class seeded_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public seeded_resultStandardScheme getScheme() { + return new seeded_resultStandardScheme(); + } + } + + private static class seeded_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, seeded_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, seeded_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class seeded_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public seeded_resultTupleScheme getScheme() { + return new seeded_resultTupleScheme(); + } + } + + private static class seeded_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, seeded_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, seeded_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + private static void unusedMethod() {} +} diff --git a/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartition.java b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartition.java new file mode 100644 index 00000000000..c88ad14f85c --- /dev/null +++ b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartition.java @@ -0,0 +1,511 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * Autogenerated by Thrift Compiler (0.17.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.accumulo.core.fate.thrift; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +public class TFatePartition implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TFatePartition"); + + private static final org.apache.thrift.protocol.TField START_FIELD_DESC = new org.apache.thrift.protocol.TField("start", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField STOP_FIELD_DESC = new org.apache.thrift.protocol.TField("stop", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TFatePartitionStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TFatePartitionTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable java.lang.String start; // required + public @org.apache.thrift.annotation.Nullable java.lang.String stop; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + START((short)1, "start"), + STOP((short)2, "stop"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // START + return START; + case 2: // STOP + return STOP; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.START, new org.apache.thrift.meta_data.FieldMetaData("start", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.STOP, new org.apache.thrift.meta_data.FieldMetaData("stop", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TFatePartition.class, metaDataMap); + } + + public TFatePartition() { + } + + public TFatePartition( + java.lang.String start, + java.lang.String stop) + { + this(); + this.start = start; + this.stop = stop; + } + + /** + * Performs a deep copy on other. + */ + public TFatePartition(TFatePartition other) { + if (other.isSetStart()) { + this.start = other.start; + } + if (other.isSetStop()) { + this.stop = other.stop; + } + } + + @Override + public TFatePartition deepCopy() { + return new TFatePartition(this); + } + + @Override + public void clear() { + this.start = null; + this.stop = null; + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getStart() { + return this.start; + } + + public TFatePartition setStart(@org.apache.thrift.annotation.Nullable java.lang.String start) { + this.start = start; + return this; + } + + public void unsetStart() { + this.start = null; + } + + /** Returns true if field start is set (has been assigned a value) and false otherwise */ + public boolean isSetStart() { + return this.start != null; + } + + public void setStartIsSet(boolean value) { + if (!value) { + this.start = null; + } + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getStop() { + return this.stop; + } + + public TFatePartition setStop(@org.apache.thrift.annotation.Nullable java.lang.String stop) { + this.stop = stop; + return this; + } + + public void unsetStop() { + this.stop = null; + } + + /** Returns true if field stop is set (has been assigned a value) and false otherwise */ + public boolean isSetStop() { + return this.stop != null; + } + + public void setStopIsSet(boolean value) { + if (!value) { + this.stop = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case START: + if (value == null) { + unsetStart(); + } else { + setStart((java.lang.String)value); + } + break; + + case STOP: + if (value == null) { + unsetStop(); + } else { + setStop((java.lang.String)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case START: + return getStart(); + + case STOP: + return getStop(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case START: + return isSetStart(); + case STOP: + return isSetStop(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof TFatePartition) + return this.equals((TFatePartition)that); + return false; + } + + public boolean equals(TFatePartition that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_start = true && this.isSetStart(); + boolean that_present_start = true && that.isSetStart(); + if (this_present_start || that_present_start) { + if (!(this_present_start && that_present_start)) + return false; + if (!this.start.equals(that.start)) + return false; + } + + boolean this_present_stop = true && this.isSetStop(); + boolean that_present_stop = true && that.isSetStop(); + if (this_present_stop || that_present_stop) { + if (!(this_present_stop && that_present_stop)) + return false; + if (!this.stop.equals(that.stop)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetStart()) ? 131071 : 524287); + if (isSetStart()) + hashCode = hashCode * 8191 + start.hashCode(); + + hashCode = hashCode * 8191 + ((isSetStop()) ? 131071 : 524287); + if (isSetStop()) + hashCode = hashCode * 8191 + stop.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(TFatePartition other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetStart(), other.isSetStart()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStart()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.start, other.start); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetStop(), other.isSetStop()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStop()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stop, other.stop); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("TFatePartition("); + boolean first = true; + + sb.append("start:"); + if (this.start == null) { + sb.append("null"); + } else { + sb.append(this.start); + } + first = false; + if (!first) sb.append(", "); + sb.append("stop:"); + if (this.stop == null) { + sb.append("null"); + } else { + sb.append(this.stop); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TFatePartitionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TFatePartitionStandardScheme getScheme() { + return new TFatePartitionStandardScheme(); + } + } + + private static class TFatePartitionStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, TFatePartition struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // START + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.start = iprot.readString(); + struct.setStartIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // STOP + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.stop = iprot.readString(); + struct.setStopIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, TFatePartition struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.start != null) { + oprot.writeFieldBegin(START_FIELD_DESC); + oprot.writeString(struct.start); + oprot.writeFieldEnd(); + } + if (struct.stop != null) { + oprot.writeFieldBegin(STOP_FIELD_DESC); + oprot.writeString(struct.stop); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TFatePartitionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TFatePartitionTupleScheme getScheme() { + return new TFatePartitionTupleScheme(); + } + } + + private static class TFatePartitionTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TFatePartition struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetStart()) { + optionals.set(0); + } + if (struct.isSetStop()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetStart()) { + oprot.writeString(struct.start); + } + if (struct.isSetStop()) { + oprot.writeString(struct.stop); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TFatePartition struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.start = iprot.readString(); + struct.setStartIsSet(true); + } + if (incoming.get(1)) { + struct.stop = iprot.readString(); + struct.setStopIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + private static void unusedMethod() {} +} + diff --git a/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartitions.java b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartitions.java new file mode 100644 index 00000000000..7d8a327484b --- /dev/null +++ b/core/src/main/thrift-gen-java/org/apache/accumulo/core/fate/thrift/TFatePartitions.java @@ -0,0 +1,561 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * Autogenerated by Thrift Compiler (0.17.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.accumulo.core.fate.thrift; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +public class TFatePartitions implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TFatePartitions"); + + private static final org.apache.thrift.protocol.TField UPDATE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("updateId", org.apache.thrift.protocol.TType.I64, (short)1); + private static final org.apache.thrift.protocol.TField PARTITIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("partitions", org.apache.thrift.protocol.TType.LIST, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TFatePartitionsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TFatePartitionsTupleSchemeFactory(); + + public long updateId; // required + public @org.apache.thrift.annotation.Nullable java.util.List partitions; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + UPDATE_ID((short)1, "updateId"), + PARTITIONS((short)2, "partitions"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // UPDATE_ID + return UPDATE_ID; + case 2: // PARTITIONS + return PARTITIONS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __UPDATEID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.UPDATE_ID, new org.apache.thrift.meta_data.FieldMetaData("updateId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.PARTITIONS, new org.apache.thrift.meta_data.FieldMetaData("partitions", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TFatePartition.class)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TFatePartitions.class, metaDataMap); + } + + public TFatePartitions() { + } + + public TFatePartitions( + long updateId, + java.util.List partitions) + { + this(); + this.updateId = updateId; + setUpdateIdIsSet(true); + this.partitions = partitions; + } + + /** + * Performs a deep copy on other. + */ + public TFatePartitions(TFatePartitions other) { + __isset_bitfield = other.__isset_bitfield; + this.updateId = other.updateId; + if (other.isSetPartitions()) { + java.util.List __this__partitions = new java.util.ArrayList(other.partitions.size()); + for (TFatePartition other_element : other.partitions) { + __this__partitions.add(new TFatePartition(other_element)); + } + this.partitions = __this__partitions; + } + } + + @Override + public TFatePartitions deepCopy() { + return new TFatePartitions(this); + } + + @Override + public void clear() { + setUpdateIdIsSet(false); + this.updateId = 0; + this.partitions = null; + } + + public long getUpdateId() { + return this.updateId; + } + + public TFatePartitions setUpdateId(long updateId) { + this.updateId = updateId; + setUpdateIdIsSet(true); + return this; + } + + public void unsetUpdateId() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEID_ISSET_ID); + } + + /** Returns true if field updateId is set (has been assigned a value) and false otherwise */ + public boolean isSetUpdateId() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEID_ISSET_ID); + } + + public void setUpdateIdIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEID_ISSET_ID, value); + } + + public int getPartitionsSize() { + return (this.partitions == null) ? 0 : this.partitions.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getPartitionsIterator() { + return (this.partitions == null) ? null : this.partitions.iterator(); + } + + public void addToPartitions(TFatePartition elem) { + if (this.partitions == null) { + this.partitions = new java.util.ArrayList(); + } + this.partitions.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getPartitions() { + return this.partitions; + } + + public TFatePartitions setPartitions(@org.apache.thrift.annotation.Nullable java.util.List partitions) { + this.partitions = partitions; + return this; + } + + public void unsetPartitions() { + this.partitions = null; + } + + /** Returns true if field partitions is set (has been assigned a value) and false otherwise */ + public boolean isSetPartitions() { + return this.partitions != null; + } + + public void setPartitionsIsSet(boolean value) { + if (!value) { + this.partitions = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case UPDATE_ID: + if (value == null) { + unsetUpdateId(); + } else { + setUpdateId((java.lang.Long)value); + } + break; + + case PARTITIONS: + if (value == null) { + unsetPartitions(); + } else { + setPartitions((java.util.List)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case UPDATE_ID: + return getUpdateId(); + + case PARTITIONS: + return getPartitions(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case UPDATE_ID: + return isSetUpdateId(); + case PARTITIONS: + return isSetPartitions(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof TFatePartitions) + return this.equals((TFatePartitions)that); + return false; + } + + public boolean equals(TFatePartitions that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_updateId = true; + boolean that_present_updateId = true; + if (this_present_updateId || that_present_updateId) { + if (!(this_present_updateId && that_present_updateId)) + return false; + if (this.updateId != that.updateId) + return false; + } + + boolean this_present_partitions = true && this.isSetPartitions(); + boolean that_present_partitions = true && that.isSetPartitions(); + if (this_present_partitions || that_present_partitions) { + if (!(this_present_partitions && that_present_partitions)) + return false; + if (!this.partitions.equals(that.partitions)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updateId); + + hashCode = hashCode * 8191 + ((isSetPartitions()) ? 131071 : 524287); + if (isSetPartitions()) + hashCode = hashCode * 8191 + partitions.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(TFatePartitions other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetUpdateId(), other.isSetUpdateId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUpdateId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updateId, other.updateId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetPartitions(), other.isSetPartitions()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPartitions()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partitions, other.partitions); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("TFatePartitions("); + boolean first = true; + + sb.append("updateId:"); + sb.append(this.updateId); + first = false; + if (!first) sb.append(", "); + sb.append("partitions:"); + if (this.partitions == null) { + sb.append("null"); + } else { + sb.append(this.partitions); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TFatePartitionsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TFatePartitionsStandardScheme getScheme() { + return new TFatePartitionsStandardScheme(); + } + } + + private static class TFatePartitionsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, TFatePartitions struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // UPDATE_ID + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.updateId = iprot.readI64(); + struct.setUpdateIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PARTITIONS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); + struct.partitions = new java.util.ArrayList(_list0.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem1; + for (int _i2 = 0; _i2 < _list0.size; ++_i2) + { + _elem1 = new TFatePartition(); + _elem1.read(iprot); + struct.partitions.add(_elem1); + } + iprot.readListEnd(); + } + struct.setPartitionsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, TFatePartitions struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(UPDATE_ID_FIELD_DESC); + oprot.writeI64(struct.updateId); + oprot.writeFieldEnd(); + if (struct.partitions != null) { + oprot.writeFieldBegin(PARTITIONS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.partitions.size())); + for (TFatePartition _iter3 : struct.partitions) + { + _iter3.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TFatePartitionsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TFatePartitionsTupleScheme getScheme() { + return new TFatePartitionsTupleScheme(); + } + } + + private static class TFatePartitionsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TFatePartitions struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetUpdateId()) { + optionals.set(0); + } + if (struct.isSetPartitions()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetUpdateId()) { + oprot.writeI64(struct.updateId); + } + if (struct.isSetPartitions()) { + { + oprot.writeI32(struct.partitions.size()); + for (TFatePartition _iter4 : struct.partitions) + { + _iter4.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TFatePartitions struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.updateId = iprot.readI64(); + struct.setUpdateIdIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TList _list5 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.partitions = new java.util.ArrayList(_list5.size); + @org.apache.thrift.annotation.Nullable TFatePartition _elem6; + for (int _i7 = 0; _i7 < _list5.size; ++_i7) + { + _elem6 = new TFatePartition(); + _elem6.read(iprot); + struct.partitions.add(_elem6); + } + } + struct.setPartitionsIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + private static void unusedMethod() {} +} + diff --git a/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/ManagerClientService.java b/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/ManagerClientService.java index 9e845fbdcd3..4dba34f0079 100644 --- a/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/ManagerClientService.java +++ b/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/ManagerClientService.java @@ -85,6 +85,8 @@ public interface Iface { public long getManagerTimeNanos(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) throws org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException, org.apache.thrift.TException; + public void processEvents(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events) throws org.apache.thrift.TException; + } public interface AsyncIface { @@ -145,6 +147,8 @@ public interface AsyncIface { public void getManagerTimeNanos(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void processEvents(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + } public static class Client extends org.apache.thrift.TServiceClient implements Iface { @@ -1069,6 +1073,29 @@ public long recv_getManagerTimeNanos() throws org.apache.accumulo.core.clientImp throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getManagerTimeNanos failed: unknown result"); } + @Override + public void processEvents(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events) throws org.apache.thrift.TException + { + send_processEvents(tinfo, credentials, events); + recv_processEvents(); + } + + public void send_processEvents(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events) throws org.apache.thrift.TException + { + processEvents_args args = new processEvents_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setEvents(events); + sendBase("processEvents", args); + } + + public void recv_processEvents() throws org.apache.thrift.TException + { + processEvents_result result = new processEvents_result(); + receiveBase(result, "processEvents"); + return; + } + } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { @@ -2311,6 +2338,48 @@ public java.lang.Long getResult() throws org.apache.accumulo.core.clientImpl.thr } } + @Override + public void processEvents(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + processEvents_call method_call = new processEvents_call(tinfo, credentials, events, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class processEvents_call extends org.apache.thrift.async.TAsyncMethodCall { + private org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; + private org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; + private java.util.List events; + public processEvents_call(org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, java.util.List events, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.tinfo = tinfo; + this.credentials = credentials; + this.events = events; + } + + @Override + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("processEvents", org.apache.thrift.protocol.TMessageType.CALL, 0)); + processEvents_args args = new processEvents_args(); + args.setTinfo(tinfo); + args.setCredentials(credentials); + args.setEvents(events); + args.write(prot); + prot.writeMessageEnd(); + } + + @Override + public Void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_processEvents(); + return null; + } + } + } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { @@ -2352,6 +2421,7 @@ protected Processor(I iface, java.util.Map extends org.apache.thrift.ProcessFunction { + public processEvents() { + super("processEvents"); + } + + @Override + public processEvents_args getEmptyArgsInstance() { + return new processEvents_args(); + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + @Override + public processEvents_result getResult(I iface, processEvents_args args) throws org.apache.thrift.TException { + processEvents_result result = new processEvents_result(); + iface.processEvents(args.tinfo, args.credentials, args.events); + return result; + } + } + } public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { @@ -3387,6 +3485,7 @@ protected AsyncProcessor(I iface, java.util.Map extends org.apache.thrift.AsyncProcessFunction { + public processEvents() { + super("processEvents"); + } + + @Override + public processEvents_args getEmptyArgsInstance() { + return new processEvents_args(); + } + + @Override + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + @Override + public void onComplete(Void o) { + processEvents_result result = new processEvents_result(); + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + @Override + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + processEvents_result result = new processEvents_result(); + if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + public void start(I iface, processEvents_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.processEvents(args.tinfo, args.credentials, args.events,resultHandler); + } + } + } @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @@ -39722,42 +39887,1036 @@ public java.lang.String getFieldName() { tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.securityImpl.thrift.TCredentials.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getManagerTimeNanos_args.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getManagerTimeNanos_args.class, metaDataMap); + } + + public getManagerTimeNanos_args() { + } + + public getManagerTimeNanos_args( + org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, + org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) + { + this(); + this.tinfo = tinfo; + this.credentials = credentials; + } + + /** + * Performs a deep copy on other. + */ + public getManagerTimeNanos_args(getManagerTimeNanos_args other) { + if (other.isSetTinfo()) { + this.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(other.tinfo); + } + if (other.isSetCredentials()) { + this.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(other.credentials); + } + } + + @Override + public getManagerTimeNanos_args deepCopy() { + return new getManagerTimeNanos_args(this); + } + + @Override + public void clear() { + this.tinfo = null; + this.credentials = null; + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.TInfo getTinfo() { + return this.tinfo; + } + + public getManagerTimeNanos_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { + this.tinfo = tinfo; + return this; + } + + public void unsetTinfo() { + this.tinfo = null; + } + + /** Returns true if field tinfo is set (has been assigned a value) and false otherwise */ + public boolean isSetTinfo() { + return this.tinfo != null; + } + + public void setTinfoIsSet(boolean value) { + if (!value) { + this.tinfo = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.securityImpl.thrift.TCredentials getCredentials() { + return this.credentials; + } + + public getManagerTimeNanos_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { + this.credentials = credentials; + return this; + } + + public void unsetCredentials() { + this.credentials = null; + } + + /** Returns true if field credentials is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentials() { + return this.credentials != null; + } + + public void setCredentialsIsSet(boolean value) { + if (!value) { + this.credentials = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case TINFO: + if (value == null) { + unsetTinfo(); + } else { + setTinfo((org.apache.accumulo.core.clientImpl.thrift.TInfo)value); + } + break; + + case CREDENTIALS: + if (value == null) { + unsetCredentials(); + } else { + setCredentials((org.apache.accumulo.core.securityImpl.thrift.TCredentials)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case TINFO: + return getTinfo(); + + case CREDENTIALS: + return getCredentials(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case TINFO: + return isSetTinfo(); + case CREDENTIALS: + return isSetCredentials(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getManagerTimeNanos_args) + return this.equals((getManagerTimeNanos_args)that); + return false; + } + + public boolean equals(getManagerTimeNanos_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_tinfo = true && this.isSetTinfo(); + boolean that_present_tinfo = true && that.isSetTinfo(); + if (this_present_tinfo || that_present_tinfo) { + if (!(this_present_tinfo && that_present_tinfo)) + return false; + if (!this.tinfo.equals(that.tinfo)) + return false; + } + + boolean this_present_credentials = true && this.isSetCredentials(); + boolean that_present_credentials = true && that.isSetCredentials(); + if (this_present_credentials || that_present_credentials) { + if (!(this_present_credentials && that_present_credentials)) + return false; + if (!this.credentials.equals(that.credentials)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTinfo()) ? 131071 : 524287); + if (isSetTinfo()) + hashCode = hashCode * 8191 + tinfo.hashCode(); + + hashCode = hashCode * 8191 + ((isSetCredentials()) ? 131071 : 524287); + if (isSetCredentials()) + hashCode = hashCode * 8191 + credentials.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getManagerTimeNanos_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetTinfo(), other.isSetTinfo()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTinfo()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tinfo, other.tinfo); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetCredentials(), other.isSetCredentials()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentials()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentials, other.credentials); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getManagerTimeNanos_args("); + boolean first = true; + + sb.append("tinfo:"); + if (this.tinfo == null) { + sb.append("null"); + } else { + sb.append(this.tinfo); + } + first = false; + if (!first) sb.append(", "); + sb.append("credentials:"); + if (this.credentials == null) { + sb.append("null"); + } else { + sb.append(this.credentials); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (tinfo != null) { + tinfo.validate(); + } + if (credentials != null) { + credentials.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getManagerTimeNanos_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getManagerTimeNanos_argsStandardScheme getScheme() { + return new getManagerTimeNanos_argsStandardScheme(); + } + } + + private static class getManagerTimeNanos_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TINFO + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // CREDENTIALS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.tinfo != null) { + oprot.writeFieldBegin(TINFO_FIELD_DESC); + struct.tinfo.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.credentials != null) { + oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); + struct.credentials.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getManagerTimeNanos_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getManagerTimeNanos_argsTupleScheme getScheme() { + return new getManagerTimeNanos_argsTupleScheme(); + } + } + + private static class getManagerTimeNanos_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetTinfo()) { + optionals.set(0); + } + if (struct.isSetCredentials()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetTinfo()) { + struct.tinfo.write(oprot); + } + if (struct.isSetCredentials()) { + struct.credentials.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); + struct.tinfo.read(iprot); + struct.setTinfoIsSet(true); + } + if (incoming.get(1)) { + struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); + struct.credentials.read(iprot); + struct.setCredentialsIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class getManagerTimeNanos_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getManagerTimeNanos_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I64, (short)0); + private static final org.apache.thrift.protocol.TField SEC_FIELD_DESC = new org.apache.thrift.protocol.TField("sec", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getManagerTimeNanos_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getManagerTimeNanos_resultTupleSchemeFactory(); + + public long success; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + SEC((short)1, "sec"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // SEC + return SEC; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SUCCESS_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.SEC, new org.apache.thrift.meta_data.FieldMetaData("sec", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getManagerTimeNanos_result.class, metaDataMap); + } + + public getManagerTimeNanos_result() { + } + + public getManagerTimeNanos_result( + long success, + org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) + { + this(); + this.success = success; + setSuccessIsSet(true); + this.sec = sec; + } + + /** + * Performs a deep copy on other. + */ + public getManagerTimeNanos_result(getManagerTimeNanos_result other) { + __isset_bitfield = other.__isset_bitfield; + this.success = other.success; + if (other.isSetSec()) { + this.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(other.sec); + } + } + + @Override + public getManagerTimeNanos_result deepCopy() { + return new getManagerTimeNanos_result(this); + } + + @Override + public void clear() { + setSuccessIsSet(false); + this.success = 0; + this.sec = null; + } + + public long getSuccess() { + return this.success; + } + + public getManagerTimeNanos_result setSuccess(long success) { + this.success = success; + setSuccessIsSet(true); + return this; + } + + public void unsetSuccess() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + public void setSuccessIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException getSec() { + return this.sec; + } + + public getManagerTimeNanos_result setSec(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { + this.sec = sec; + return this; + } + + public void unsetSec() { + this.sec = null; + } + + /** Returns true if field sec is set (has been assigned a value) and false otherwise */ + public boolean isSetSec() { + return this.sec != null; + } + + public void setSecIsSet(boolean value) { + if (!value) { + this.sec = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((java.lang.Long)value); + } + break; + + case SEC: + if (value == null) { + unsetSec(); + } else { + setSec((org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case SEC: + return getSec(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case SEC: + return isSetSec(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getManagerTimeNanos_result) + return this.equals((getManagerTimeNanos_result)that); + return false; + } + + public boolean equals(getManagerTimeNanos_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true; + boolean that_present_success = true; + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (this.success != that.success) + return false; + } + + boolean this_present_sec = true && this.isSetSec(); + boolean that_present_sec = true && that.isSetSec(); + if (this_present_sec || that_present_sec) { + if (!(this_present_sec && that_present_sec)) + return false; + if (!this.sec.equals(that.sec)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(success); + + hashCode = hashCode * 8191 + ((isSetSec()) ? 131071 : 524287); + if (isSetSec()) + hashCode = hashCode * 8191 + sec.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getManagerTimeNanos_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetSec(), other.isSetSec()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSec()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sec, other.sec); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getManagerTimeNanos_result("); + boolean first = true; + + sb.append("success:"); + sb.append(this.success); + first = false; + if (!first) sb.append(", "); + sb.append("sec:"); + if (this.sec == null) { + sb.append("null"); + } else { + sb.append(this.sec); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getManagerTimeNanos_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getManagerTimeNanos_resultStandardScheme getScheme() { + return new getManagerTimeNanos_resultStandardScheme(); + } + } + + private static class getManagerTimeNanos_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.success = iprot.readI64(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // SEC + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeI64(struct.success); + oprot.writeFieldEnd(); + } + if (struct.sec != null) { + oprot.writeFieldBegin(SEC_FIELD_DESC); + struct.sec.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getManagerTimeNanos_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getManagerTimeNanos_resultTupleScheme getScheme() { + return new getManagerTimeNanos_resultTupleScheme(); + } + } + + private static class getManagerTimeNanos_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetSec()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSuccess()) { + oprot.writeI64(struct.success); + } + if (struct.isSetSec()) { + struct.sec.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.success = iprot.readI64(); + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); + struct.sec.read(iprot); + struct.setSecIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class processEvents_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("processEvents_args"); + + private static final org.apache.thrift.protocol.TField TINFO_FIELD_DESC = new org.apache.thrift.protocol.TField("tinfo", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField EVENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("events", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new processEvents_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new processEvents_argsTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials; // required + public @org.apache.thrift.annotation.Nullable java.util.List events; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TINFO((short)1, "tinfo"), + CREDENTIALS((short)2, "credentials"), + EVENTS((short)3, "events"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TINFO + return TINFO; + case 2: // CREDENTIALS + return CREDENTIALS; + case 3: // EVENTS + return EVENTS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TINFO, new org.apache.thrift.meta_data.FieldMetaData("tinfo", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.TInfo.class))); + tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.securityImpl.thrift.TCredentials.class))); + tmpMap.put(_Fields.EVENTS, new org.apache.thrift.meta_data.FieldMetaData("events", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TEvent.class)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(processEvents_args.class, metaDataMap); } - public getManagerTimeNanos_args() { + public processEvents_args() { } - public getManagerTimeNanos_args( + public processEvents_args( org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo, - org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) + org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials, + java.util.List events) { this(); this.tinfo = tinfo; this.credentials = credentials; + this.events = events; } /** * Performs a deep copy on other. */ - public getManagerTimeNanos_args(getManagerTimeNanos_args other) { + public processEvents_args(processEvents_args other) { if (other.isSetTinfo()) { this.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(other.tinfo); } if (other.isSetCredentials()) { this.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(other.credentials); } + if (other.isSetEvents()) { + java.util.List __this__events = new java.util.ArrayList(other.events.size()); + for (TEvent other_element : other.events) { + __this__events.add(new TEvent(other_element)); + } + this.events = __this__events; + } } @Override - public getManagerTimeNanos_args deepCopy() { - return new getManagerTimeNanos_args(this); + public processEvents_args deepCopy() { + return new processEvents_args(this); } @Override public void clear() { this.tinfo = null; this.credentials = null; + this.events = null; } @org.apache.thrift.annotation.Nullable @@ -39765,7 +40924,7 @@ public org.apache.accumulo.core.clientImpl.thrift.TInfo getTinfo() { return this.tinfo; } - public getManagerTimeNanos_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { + public processEvents_args setTinfo(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.TInfo tinfo) { this.tinfo = tinfo; return this; } @@ -39790,7 +40949,7 @@ public org.apache.accumulo.core.securityImpl.thrift.TCredentials getCredentials( return this.credentials; } - public getManagerTimeNanos_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { + public processEvents_args setCredentials(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.securityImpl.thrift.TCredentials credentials) { this.credentials = credentials; return this; } @@ -39810,6 +40969,47 @@ public void setCredentialsIsSet(boolean value) { } } + public int getEventsSize() { + return (this.events == null) ? 0 : this.events.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getEventsIterator() { + return (this.events == null) ? null : this.events.iterator(); + } + + public void addToEvents(TEvent elem) { + if (this.events == null) { + this.events = new java.util.ArrayList(); + } + this.events.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getEvents() { + return this.events; + } + + public processEvents_args setEvents(@org.apache.thrift.annotation.Nullable java.util.List events) { + this.events = events; + return this; + } + + public void unsetEvents() { + this.events = null; + } + + /** Returns true if field events is set (has been assigned a value) and false otherwise */ + public boolean isSetEvents() { + return this.events != null; + } + + public void setEventsIsSet(boolean value) { + if (!value) { + this.events = null; + } + } + @Override public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { switch (field) { @@ -39829,6 +41029,14 @@ public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable } break; + case EVENTS: + if (value == null) { + unsetEvents(); + } else { + setEvents((java.util.List)value); + } + break; + } } @@ -39842,6 +41050,9 @@ public java.lang.Object getFieldValue(_Fields field) { case CREDENTIALS: return getCredentials(); + case EVENTS: + return getEvents(); + } throw new java.lang.IllegalStateException(); } @@ -39858,18 +41069,20 @@ public boolean isSet(_Fields field) { return isSetTinfo(); case CREDENTIALS: return isSetCredentials(); + case EVENTS: + return isSetEvents(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { - if (that instanceof getManagerTimeNanos_args) - return this.equals((getManagerTimeNanos_args)that); + if (that instanceof processEvents_args) + return this.equals((processEvents_args)that); return false; } - public boolean equals(getManagerTimeNanos_args that) { + public boolean equals(processEvents_args that) { if (that == null) return false; if (this == that) @@ -39893,6 +41106,15 @@ public boolean equals(getManagerTimeNanos_args that) { return false; } + boolean this_present_events = true && this.isSetEvents(); + boolean that_present_events = true && that.isSetEvents(); + if (this_present_events || that_present_events) { + if (!(this_present_events && that_present_events)) + return false; + if (!this.events.equals(that.events)) + return false; + } + return true; } @@ -39908,11 +41130,15 @@ public int hashCode() { if (isSetCredentials()) hashCode = hashCode * 8191 + credentials.hashCode(); + hashCode = hashCode * 8191 + ((isSetEvents()) ? 131071 : 524287); + if (isSetEvents()) + hashCode = hashCode * 8191 + events.hashCode(); + return hashCode; } @Override - public int compareTo(getManagerTimeNanos_args other) { + public int compareTo(processEvents_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } @@ -39939,6 +41165,16 @@ public int compareTo(getManagerTimeNanos_args other) { return lastComparison; } } + lastComparison = java.lang.Boolean.compare(isSetEvents(), other.isSetEvents()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetEvents()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.events, other.events); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -39960,7 +41196,7 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder("getManagerTimeNanos_args("); + java.lang.StringBuilder sb = new java.lang.StringBuilder("processEvents_args("); boolean first = true; sb.append("tinfo:"); @@ -39978,6 +41214,14 @@ public java.lang.String toString() { sb.append(this.credentials); } first = false; + if (!first) sb.append(", "); + sb.append("events:"); + if (this.events == null) { + sb.append("null"); + } else { + sb.append(this.events); + } + first = false; sb.append(")"); return sb.toString(); } @@ -40009,17 +41253,17 @@ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException } } - private static class getManagerTimeNanos_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + private static class processEvents_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { @Override - public getManagerTimeNanos_argsStandardScheme getScheme() { - return new getManagerTimeNanos_argsStandardScheme(); + public processEvents_argsStandardScheme getScheme() { + return new processEvents_argsStandardScheme(); } } - private static class getManagerTimeNanos_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + private static class processEvents_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { @Override - public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, processEvents_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -40047,6 +41291,25 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 3: // EVENTS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list130 = iprot.readListBegin(); + struct.events = new java.util.ArrayList(_list130.size); + @org.apache.thrift.annotation.Nullable TEvent _elem131; + for (int _i132 = 0; _i132 < _list130.size; ++_i132) + { + _elem131 = new TEvent(); + _elem131.read(iprot); + struct.events.add(_elem131); + } + iprot.readListEnd(); + } + struct.setEventsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -40059,7 +41322,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos } @Override - public void write(org.apache.thrift.protocol.TProtocol oprot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, processEvents_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); @@ -40073,23 +41336,35 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getManagerTimeNano struct.credentials.write(oprot); oprot.writeFieldEnd(); } + if (struct.events != null) { + oprot.writeFieldBegin(EVENTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.events.size())); + for (TEvent _iter133 : struct.events) + { + _iter133.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } } - private static class getManagerTimeNanos_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + private static class processEvents_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { @Override - public getManagerTimeNanos_argsTupleScheme getScheme() { - return new getManagerTimeNanos_argsTupleScheme(); + public processEvents_argsTupleScheme getScheme() { + return new processEvents_argsTupleScheme(); } } - private static class getManagerTimeNanos_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + private static class processEvents_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, processEvents_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetTinfo()) { @@ -40098,19 +41373,31 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos if (struct.isSetCredentials()) { optionals.set(1); } - oprot.writeBitSet(optionals, 2); + if (struct.isSetEvents()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); if (struct.isSetTinfo()) { struct.tinfo.write(oprot); } if (struct.isSetCredentials()) { struct.credentials.write(oprot); } + if (struct.isSetEvents()) { + { + oprot.writeI32(struct.events.size()); + for (TEvent _iter134 : struct.events) + { + _iter134.write(oprot); + } + } + } } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, processEvents_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(2); + java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.tinfo = new org.apache.accumulo.core.clientImpl.thrift.TInfo(); struct.tinfo.read(iprot); @@ -40121,6 +41408,20 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_ struct.credentials.read(iprot); struct.setCredentialsIsSet(true); } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list135 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.events = new java.util.ArrayList(_list135.size); + @org.apache.thrift.annotation.Nullable TEvent _elem136; + for (int _i137 = 0; _i137 < _list135.size; ++_i137) + { + _elem136 = new TEvent(); + _elem136.read(iprot); + struct.events.add(_elem136); + } + } + struct.setEventsIsSet(true); + } } } @@ -40130,22 +41431,17 @@ private static S scheme(org.apache. } @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) - public static class getManagerTimeNanos_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getManagerTimeNanos_result"); + public static class processEvents_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("processEvents_result"); - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I64, (short)0); - private static final org.apache.thrift.protocol.TField SEC_FIELD_DESC = new org.apache.thrift.protocol.TField("sec", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getManagerTimeNanos_resultStandardSchemeFactory(); - private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getManagerTimeNanos_resultTupleSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new processEvents_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new processEvents_resultTupleSchemeFactory(); - public long success; // required - public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"), - SEC((short)1, "sec"); +; private static final java.util.Map byName = new java.util.HashMap(); @@ -40161,10 +41457,6 @@ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @org.apache.thrift.annotation.Nullable public static _Fields findByThriftId(int fieldId) { switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; - case 1: // SEC - return SEC; default: return null; } @@ -40206,124 +41498,34 @@ public java.lang.String getFieldName() { return _fieldName; } } - - // isset id assignments - private static final int __SUCCESS_ISSET_ID = 0; - private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); - tmpMap.put(_Fields.SEC, new org.apache.thrift.meta_data.FieldMetaData("sec", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getManagerTimeNanos_result.class, metaDataMap); - } - - public getManagerTimeNanos_result() { + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(processEvents_result.class, metaDataMap); } - public getManagerTimeNanos_result( - long success, - org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) - { - this(); - this.success = success; - setSuccessIsSet(true); - this.sec = sec; + public processEvents_result() { } /** * Performs a deep copy on other. */ - public getManagerTimeNanos_result(getManagerTimeNanos_result other) { - __isset_bitfield = other.__isset_bitfield; - this.success = other.success; - if (other.isSetSec()) { - this.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(other.sec); - } + public processEvents_result(processEvents_result other) { } @Override - public getManagerTimeNanos_result deepCopy() { - return new getManagerTimeNanos_result(this); + public processEvents_result deepCopy() { + return new processEvents_result(this); } @Override public void clear() { - setSuccessIsSet(false); - this.success = 0; - this.sec = null; - } - - public long getSuccess() { - return this.success; - } - - public getManagerTimeNanos_result setSuccess(long success) { - this.success = success; - setSuccessIsSet(true); - return this; - } - - public void unsetSuccess() { - __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); - } - - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); - } - - public void setSuccessIsSet(boolean value) { - __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); - } - - @org.apache.thrift.annotation.Nullable - public org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException getSec() { - return this.sec; - } - - public getManagerTimeNanos_result setSec(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException sec) { - this.sec = sec; - return this; - } - - public void unsetSec() { - this.sec = null; - } - - /** Returns true if field sec is set (has been assigned a value) and false otherwise */ - public boolean isSetSec() { - return this.sec != null; - } - - public void setSecIsSet(boolean value) { - if (!value) { - this.sec = null; - } } @Override public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { switch (field) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((java.lang.Long)value); - } - break; - - case SEC: - if (value == null) { - unsetSec(); - } else { - setSec((org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)value); - } - break; - } } @@ -40331,12 +41533,6 @@ public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable @Override public java.lang.Object getFieldValue(_Fields field) { switch (field) { - case SUCCESS: - return getSuccess(); - - case SEC: - return getSec(); - } throw new java.lang.IllegalStateException(); } @@ -40349,45 +41545,23 @@ public boolean isSet(_Fields field) { } switch (field) { - case SUCCESS: - return isSetSuccess(); - case SEC: - return isSetSec(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { - if (that instanceof getManagerTimeNanos_result) - return this.equals((getManagerTimeNanos_result)that); + if (that instanceof processEvents_result) + return this.equals((processEvents_result)that); return false; } - public boolean equals(getManagerTimeNanos_result that) { + public boolean equals(processEvents_result that) { if (that == null) return false; if (this == that) return true; - boolean this_present_success = true; - boolean that_present_success = true; - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (this.success != that.success) - return false; - } - - boolean this_present_sec = true && this.isSetSec(); - boolean that_present_sec = true && that.isSetSec(); - if (this_present_sec || that_present_sec) { - if (!(this_present_sec && that_present_sec)) - return false; - if (!this.sec.equals(that.sec)) - return false; - } - return true; } @@ -40395,43 +41569,17 @@ public boolean equals(getManagerTimeNanos_result that) { public int hashCode() { int hashCode = 1; - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(success); - - hashCode = hashCode * 8191 + ((isSetSec()) ? 131071 : 524287); - if (isSetSec()) - hashCode = hashCode * 8191 + sec.hashCode(); - return hashCode; } @Override - public int compareTo(getManagerTimeNanos_result other) { + public int compareTo(processEvents_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; - lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = java.lang.Boolean.compare(isSetSec(), other.isSetSec()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSec()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sec, other.sec); - if (lastComparison != 0) { - return lastComparison; - } - } return 0; } @@ -40452,20 +41600,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder("getManagerTimeNanos_result("); + java.lang.StringBuilder sb = new java.lang.StringBuilder("processEvents_result("); boolean first = true; - sb.append("success:"); - sb.append(this.success); - first = false; - if (!first) sb.append(", "); - sb.append("sec:"); - if (this.sec == null) { - sb.append("null"); - } else { - sb.append(this.sec); - } - first = false; sb.append(")"); return sb.toString(); } @@ -40485,25 +41622,23 @@ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOExcept private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } - private static class getManagerTimeNanos_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + private static class processEvents_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { @Override - public getManagerTimeNanos_resultStandardScheme getScheme() { - return new getManagerTimeNanos_resultStandardScheme(); + public processEvents_resultStandardScheme getScheme() { + return new processEvents_resultStandardScheme(); } } - private static class getManagerTimeNanos_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + private static class processEvents_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { @Override - public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, processEvents_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -40513,23 +41648,6 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos break; } switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.I64) { - struct.success = iprot.readI64(); - struct.setSuccessIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 1: // SEC - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); - struct.sec.read(iprot); - struct.setSecIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -40542,67 +41660,33 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getManagerTimeNanos } @Override - public void write(org.apache.thrift.protocol.TProtocol oprot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, processEvents_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); - if (struct.isSetSuccess()) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - oprot.writeI64(struct.success); - oprot.writeFieldEnd(); - } - if (struct.sec != null) { - oprot.writeFieldBegin(SEC_FIELD_DESC); - struct.sec.write(oprot); - oprot.writeFieldEnd(); - } oprot.writeFieldStop(); oprot.writeStructEnd(); } } - private static class getManagerTimeNanos_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + private static class processEvents_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { @Override - public getManagerTimeNanos_resultTupleScheme getScheme() { - return new getManagerTimeNanos_resultTupleScheme(); + public processEvents_resultTupleScheme getScheme() { + return new processEvents_resultTupleScheme(); } } - private static class getManagerTimeNanos_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + private static class processEvents_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, processEvents_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet optionals = new java.util.BitSet(); - if (struct.isSetSuccess()) { - optionals.set(0); - } - if (struct.isSetSec()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetSuccess()) { - oprot.writeI64(struct.success); - } - if (struct.isSetSec()) { - struct.sec.write(oprot); - } } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getManagerTimeNanos_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, processEvents_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.success = iprot.readI64(); - struct.setSuccessIsSet(true); - } - if (incoming.get(1)) { - struct.sec = new org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException(); - struct.sec.read(iprot); - struct.setSecIsSet(true); - } } } diff --git a/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/TEvent.java b/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/TEvent.java new file mode 100644 index 00000000000..e6200c0a698 --- /dev/null +++ b/core/src/main/thrift-gen-java/org/apache/accumulo/core/manager/thrift/TEvent.java @@ -0,0 +1,516 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * Autogenerated by Thrift Compiler (0.17.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.accumulo.core.manager.thrift; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +public class TEvent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TEvent"); + + private static final org.apache.thrift.protocol.TField LEVEL_FIELD_DESC = new org.apache.thrift.protocol.TField("level", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField EXTENT_FIELD_DESC = new org.apache.thrift.protocol.TField("extent", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TEventStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TEventTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable java.lang.String level; // required + public @org.apache.thrift.annotation.Nullable org.apache.accumulo.core.dataImpl.thrift.TKeyExtent extent; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + LEVEL((short)1, "level"), + EXTENT((short)2, "extent"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // LEVEL + return LEVEL; + case 2: // EXTENT + return EXTENT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.LEVEL, new org.apache.thrift.meta_data.FieldMetaData("level", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.EXTENT, new org.apache.thrift.meta_data.FieldMetaData("extent", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.dataImpl.thrift.TKeyExtent.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TEvent.class, metaDataMap); + } + + public TEvent() { + } + + public TEvent( + java.lang.String level, + org.apache.accumulo.core.dataImpl.thrift.TKeyExtent extent) + { + this(); + this.level = level; + this.extent = extent; + } + + /** + * Performs a deep copy on other. + */ + public TEvent(TEvent other) { + if (other.isSetLevel()) { + this.level = other.level; + } + if (other.isSetExtent()) { + this.extent = new org.apache.accumulo.core.dataImpl.thrift.TKeyExtent(other.extent); + } + } + + @Override + public TEvent deepCopy() { + return new TEvent(this); + } + + @Override + public void clear() { + this.level = null; + this.extent = null; + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getLevel() { + return this.level; + } + + public TEvent setLevel(@org.apache.thrift.annotation.Nullable java.lang.String level) { + this.level = level; + return this; + } + + public void unsetLevel() { + this.level = null; + } + + /** Returns true if field level is set (has been assigned a value) and false otherwise */ + public boolean isSetLevel() { + return this.level != null; + } + + public void setLevelIsSet(boolean value) { + if (!value) { + this.level = null; + } + } + + @org.apache.thrift.annotation.Nullable + public org.apache.accumulo.core.dataImpl.thrift.TKeyExtent getExtent() { + return this.extent; + } + + public TEvent setExtent(@org.apache.thrift.annotation.Nullable org.apache.accumulo.core.dataImpl.thrift.TKeyExtent extent) { + this.extent = extent; + return this; + } + + public void unsetExtent() { + this.extent = null; + } + + /** Returns true if field extent is set (has been assigned a value) and false otherwise */ + public boolean isSetExtent() { + return this.extent != null; + } + + public void setExtentIsSet(boolean value) { + if (!value) { + this.extent = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case LEVEL: + if (value == null) { + unsetLevel(); + } else { + setLevel((java.lang.String)value); + } + break; + + case EXTENT: + if (value == null) { + unsetExtent(); + } else { + setExtent((org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case LEVEL: + return getLevel(); + + case EXTENT: + return getExtent(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case LEVEL: + return isSetLevel(); + case EXTENT: + return isSetExtent(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof TEvent) + return this.equals((TEvent)that); + return false; + } + + public boolean equals(TEvent that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_level = true && this.isSetLevel(); + boolean that_present_level = true && that.isSetLevel(); + if (this_present_level || that_present_level) { + if (!(this_present_level && that_present_level)) + return false; + if (!this.level.equals(that.level)) + return false; + } + + boolean this_present_extent = true && this.isSetExtent(); + boolean that_present_extent = true && that.isSetExtent(); + if (this_present_extent || that_present_extent) { + if (!(this_present_extent && that_present_extent)) + return false; + if (!this.extent.equals(that.extent)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetLevel()) ? 131071 : 524287); + if (isSetLevel()) + hashCode = hashCode * 8191 + level.hashCode(); + + hashCode = hashCode * 8191 + ((isSetExtent()) ? 131071 : 524287); + if (isSetExtent()) + hashCode = hashCode * 8191 + extent.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(TEvent other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetLevel(), other.isSetLevel()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLevel()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.level, other.level); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetExtent(), other.isSetExtent()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetExtent()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.extent, other.extent); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("TEvent("); + boolean first = true; + + sb.append("level:"); + if (this.level == null) { + sb.append("null"); + } else { + sb.append(this.level); + } + first = false; + if (!first) sb.append(", "); + sb.append("extent:"); + if (this.extent == null) { + sb.append("null"); + } else { + sb.append(this.extent); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (extent != null) { + extent.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class TEventStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TEventStandardScheme getScheme() { + return new TEventStandardScheme(); + } + } + + private static class TEventStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, TEvent struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // LEVEL + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.level = iprot.readString(); + struct.setLevelIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // EXTENT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.extent = new org.apache.accumulo.core.dataImpl.thrift.TKeyExtent(); + struct.extent.read(iprot); + struct.setExtentIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, TEvent struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.level != null) { + oprot.writeFieldBegin(LEVEL_FIELD_DESC); + oprot.writeString(struct.level); + oprot.writeFieldEnd(); + } + if (struct.extent != null) { + oprot.writeFieldBegin(EXTENT_FIELD_DESC); + struct.extent.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TEventTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public TEventTupleScheme getScheme() { + return new TEventTupleScheme(); + } + } + + private static class TEventTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TEvent struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetLevel()) { + optionals.set(0); + } + if (struct.isSetExtent()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetLevel()) { + oprot.writeString(struct.level); + } + if (struct.isSetExtent()) { + struct.extent.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TEvent struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.level = iprot.readString(); + struct.setLevelIsSet(true); + } + if (incoming.get(1)) { + struct.extent = new org.apache.accumulo.core.dataImpl.thrift.TKeyExtent(); + struct.extent.read(iprot); + struct.setExtentIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + private static void unusedMethod() {} +} + diff --git a/core/src/main/thrift/fate-worker.thrift b/core/src/main/thrift/fate-worker.thrift new file mode 100644 index 00000000000..01e1475d688 --- /dev/null +++ b/core/src/main/thrift/fate-worker.thrift @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +namespace java org.apache.accumulo.core.fate.thrift +namespace cpp org.apache.accumulo.core.fate.thrift + +include "client.thrift" +include "security.thrift" + +struct TFatePartitions { + 1:i64 updateId + 2:list partitions +} + +struct TFatePartition { + 1:string start + 2:string stop +} + +service FateWorkerService { + + TFatePartitions getPartitions( + 1:client.TInfo tinfo, + 2:security.TCredentials credentials + ) throws ( + 1:client.ThriftSecurityException sec + ) + + bool setPartitions( + 1:client.TInfo tinfo, + 2:security.TCredentials credentials, + 3:i64 updateId, + 4:list desired + ) throws ( + 1:client.ThriftSecurityException sec + ) + + void seeded( + 1:client.TInfo tinfo, + 2:security.TCredentials credentials, + 3:list tpartitions + ) +} diff --git a/core/src/main/thrift/manager.thrift b/core/src/main/thrift/manager.thrift index 436d365e979..318805430b7 100644 --- a/core/src/main/thrift/manager.thrift +++ b/core/src/main/thrift/manager.thrift @@ -182,6 +182,11 @@ struct TTabletMergeability { 2:i64 delay } +struct TEvent { + 1:string level + 2:data.TKeyExtent extent +} + service FateService { // register a fate operation by reserving an opid @@ -239,7 +244,7 @@ service FateService { 1:client.ThriftSecurityException sec 2:client.ThriftNotActiveServiceException tnase ) - + } service ManagerClientService { @@ -371,7 +376,7 @@ service ManagerClientService { 1:client.ThriftSecurityException sec 2:client.ThriftNotActiveServiceException tnase ) - + void tabletServerStopping( 1:client.TInfo tinfo 2:security.TCredentials credentials @@ -392,7 +397,7 @@ service ManagerClientService { 2:client.ThriftNotActiveServiceException tnase 3:ThriftPropertyException tpe ) - + void modifySystemProperties( 1:client.TInfo tinfo 2:security.TCredentials credentials @@ -421,7 +426,7 @@ service ManagerClientService { 1:client.ThriftSecurityException sec 2:client.ThriftNotActiveServiceException tnase ) - + void removeResourceGroupNode( 1:client.TInfo tinfo 2:security.TCredentials credentials @@ -429,9 +434,9 @@ service ManagerClientService { ) throws ( 1:client.ThriftSecurityException sec 2:client.ThriftNotActiveServiceException tnase - 3:client.ThriftResourceGroupNotExistsException rgne + 3:client.ThriftResourceGroupNotExistsException rgne ) - + void setResourceGroupProperty( 1:client.TInfo tinfo 2:security.TCredentials credentials @@ -444,7 +449,7 @@ service ManagerClientService { 3:ThriftPropertyException tpe 4:client.ThriftResourceGroupNotExistsException rgne ) - + void modifyResourceGroupProperties( 1:client.TInfo tinfo 2:security.TCredentials credentials @@ -537,4 +542,10 @@ service ManagerClientService { ) throws ( 1:client.ThriftSecurityException sec ) + + void processEvents( + 1:client.TInfo tinfo + 2:security.TCredentials credentials + 3:list events + ) } diff --git a/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java b/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java index e4d057fc108..ff8594d133d 100644 --- a/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java +++ b/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java @@ -30,7 +30,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.stream.Stream; @@ -85,6 +85,9 @@ public FateTxStore reserve(FateId fateId) { return new TestFateTxStore(fateId); } + @Override + public void seeded() {} + @Override public Optional> tryReserve(FateId fateId) { synchronized (this) { @@ -97,13 +100,13 @@ public Optional> tryReserve(FateId fateId) { } @Override - public Map getActiveReservations() { + public Map getActiveReservations(Set partitions) { // This method only makes sense for the FateStores that don't store their reservations in memory throw new UnsupportedOperationException(); } @Override - public void deleteDeadReservations() { + public void deleteDeadReservations(Set partitions) { // This method only makes sense for the FateStores that don't store their reservations in memory throw new UnsupportedOperationException(); } @@ -273,7 +276,8 @@ public Stream list(FateKey.FateKeyType type) { } @Override - public void runnable(AtomicBoolean keepWaiting, Consumer idConsumer) { + public void runnable(Set partitions, BooleanSupplier keepWaiting, + Consumer idConsumer) { throw new UnsupportedOperationException(); } diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/ZooKeeperInitializer.java b/server/base/src/main/java/org/apache/accumulo/server/init/ZooKeeperInitializer.java index 3dde58446c3..464a6dae5a6 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/init/ZooKeeperInitializer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/init/ZooKeeperInitializer.java @@ -176,6 +176,8 @@ void initialize(final ServerContext context, final String rootTabletDirName, ZooUtil.NodeExistsPolicy.FAIL); zrwChroot.putPersistentData(Constants.ZCOMPACTIONS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL); + zrwChroot.putPersistentData(Constants.ZMANAGER_ASSISTANT_LOCK, EMPTY_BYTE_ARRAY, + ZooUtil.NodeExistsPolicy.FAIL); } /** diff --git a/server/base/src/main/java/org/apache/accumulo/server/rpc/ThriftProcessorTypes.java b/server/base/src/main/java/org/apache/accumulo/server/rpc/ThriftProcessorTypes.java index 0a56b4e32fe..975c7ca3fdb 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/rpc/ThriftProcessorTypes.java +++ b/server/base/src/main/java/org/apache/accumulo/server/rpc/ThriftProcessorTypes.java @@ -21,6 +21,7 @@ import org.apache.accumulo.core.clientImpl.thrift.ClientService; import org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService; import org.apache.accumulo.core.compaction.thrift.CompactorService; +import org.apache.accumulo.core.fate.thrift.FateWorkerService; import org.apache.accumulo.core.gc.thrift.GCMonitorService; import org.apache.accumulo.core.manager.thrift.FateService; import org.apache.accumulo.core.manager.thrift.ManagerClientService; @@ -82,6 +83,9 @@ public > TProcessor getTProcessor( private static final ThriftProcessorTypes MANAGER = new ThriftProcessorTypes<>(ThriftClientTypes.MANAGER); + private static final ThriftProcessorTypes FATE_WORKER = + new ThriftProcessorTypes<>(ThriftClientTypes.FATE_WORKER); + @VisibleForTesting public static final ThriftProcessorTypes TABLET_SERVER = new ThriftProcessorTypes<>(ThriftClientTypes.TABLET_SERVER); @@ -143,6 +147,15 @@ public static TMultiplexedProcessor getManagerTProcessor( return muxProcessor; } + public static TMultiplexedProcessor + getManagerWorkerTProcessor(FateWorkerService.Iface fateWorkerHandler, ServerContext context) { + TMultiplexedProcessor muxProcessor = new TMultiplexedProcessor(); + muxProcessor.registerProcessor(FATE_WORKER.getServiceName(), + FATE_WORKER.getTProcessor(FateWorkerService.Processor.class, FateWorkerService.Iface.class, + fateWorkerHandler, context)); + return muxProcessor; + } + public static TMultiplexedProcessor getScanServerTProcessor( ServerProcessService.Iface processHandler, ClientServiceHandler clientHandler, TabletScanClientService.Iface tserverHandler, ServerContext context) { diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ServiceStatus.java b/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ServiceStatus.java index 3301b7906ea..2a791313c8d 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ServiceStatus.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ServiceStatus.java @@ -96,6 +96,9 @@ public void execute(JCommander cl, ServiceStatusCmdOpts options) throws Exceptio final Map services = new TreeMap<>(); + // FOLLOW_ON display information about multiple managers. Could display which is primary. Also, + // could potentially display the additional port that is being listened on by the assistant + // manager. services.put(ServiceStatusReport.ReportKey.MANAGER, getManagerStatus(context)); services.put(ServiceStatusReport.ReportKey.MONITOR, getMonitorStatus(context)); services.put(ServiceStatusReport.ReportKey.T_SERVER, getTServerStatus(context)); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/EventCoordinator.java b/server/manager/src/main/java/org/apache/accumulo/manager/EventCoordinator.java index c1ada4b2371..9ab22e92262 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/EventCoordinator.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/EventCoordinator.java @@ -20,10 +20,12 @@ import java.util.Collection; import java.util.EnumMap; +import java.util.Iterator; import java.util.Map; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; +import org.apache.accumulo.core.manager.thrift.TEvent; import org.apache.accumulo.core.metadata.schema.Ample; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,30 +66,61 @@ public static class Event { private final Ample.DataLevel level; private final KeyExtent extent; - Event(KeyExtent extent) { + public Event(KeyExtent extent) { this.scope = EventScope.TABLE_RANGE; this.level = Ample.DataLevel.of(extent.tableId()); this.extent = extent; } - Event(TableId tableId) { + public Event(TableId tableId) { this.scope = EventScope.TABLE; this.level = Ample.DataLevel.of(tableId); this.extent = new KeyExtent(tableId, null, null); } - Event(Ample.DataLevel level) { + public Event(Ample.DataLevel level) { this.scope = EventScope.DATA_LEVEL; this.level = level; this.extent = null; } - Event() { + public Event() { this.scope = EventScope.ALL; this.level = null; this.extent = null; } + public TEvent toThrift() { + switch (scope) { + case ALL: + return new TEvent(null, null); + case DATA_LEVEL: + return new TEvent(getLevel().toString(), null); + case TABLE: + case TABLE_RANGE: + return new TEvent(null, getExtent().toThrift()); + default: + throw new IllegalStateException("scope : " + scope); + } + } + + public static Event fromThrift(TEvent tEvent) { + if (tEvent.getLevel() == null && tEvent.getExtent() == null) { + return new Event(); + } else if (tEvent.getLevel() != null && tEvent.getExtent() == null) { + return new Event(Ample.DataLevel.valueOf(tEvent.getLevel())); + } else if (tEvent.getLevel() == null && tEvent.getExtent() != null) { + var extent = KeyExtent.fromThrift(tEvent.getExtent()); + if (extent.endRow() == null && extent.prevEndRow() == null) { + return new Event(extent.tableId()); + } else { + return new Event(extent); + } + } else { + throw new IllegalArgumentException("Illegal TEvent " + tEvent); + } + } + public EventScope getScope() { return scope; } @@ -106,6 +139,10 @@ public KeyExtent getExtent() { Preconditions.checkState(scope == EventScope.TABLE || scope == EventScope.TABLE_RANGE); return extent; } + + public String toString() { + return "{ scope:" + scope + ", level:" + level + ", extent:" + extent + " }"; + } } @Override @@ -132,6 +169,10 @@ public void event(KeyExtent extent, String msg, Object... args) { publish(new Event(extent)); } + public void events(Iterator events) { + events.forEachRemaining(this::publish); + } + @Override public void event(Collection extents, String msg, Object... args) { if (!extents.isEmpty()) { diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java index 6c31e9174b7..615ea1a0d22 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java @@ -132,7 +132,7 @@ public TFateId beginFateOperation(TInfo tinfo, TCredentials credentials, TFateIn throws ThriftSecurityException { authenticate(credentials); return new TFateId(type, - manager.fate(FateInstanceType.fromThrift(type)).startTransaction().getTxUUIDStr()); + manager.fateClient(FateInstanceType.fromThrift(type)).startTransaction().getTxUUIDStr()); } @Override @@ -157,7 +157,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Create " + namespace + " namespace."; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new CreateNamespace(c.getPrincipal(), namespace, options)), autoCleanup, goalMessage); break; @@ -176,7 +176,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Rename " + oldName + " namespace to " + newName; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new RenameNamespace(namespaceId, oldName, newName)), autoCleanup, goalMessage); break; @@ -194,7 +194,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Delete namespace Id: " + namespaceId; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new DeleteNamespace(namespaceId)), autoCleanup, goalMessage); break; } @@ -252,7 +252,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Create table " + tableName + " " + initialTableState + " with " + splitCount + " splits and initial tabletAvailability of " + initialTabletAvailability; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new CreateTable(c.getPrincipal(), tableName, timeType, options, splitsPath, splitCount, splitsDirsPath, initialTableState, // Set the default tablet to be auto-mergeable with other tablets if it is split @@ -288,7 +288,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Rename table " + oldTableName + "(" + tableId + ") to " + oldTableName; try { - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new RenameTable(namespaceId, tableId, oldTableName, newTableName)), autoCleanup, goalMessage); } catch (NamespaceNotFoundException e) { @@ -370,7 +370,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += " and keep offline."; } - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new CloneTable(c.getPrincipal(), srcNamespaceId, srcTableId, namespaceId, tableName, propertiesToSet, propertiesToExclude, keepOffline)), autoCleanup, goalMessage); @@ -400,7 +400,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Delete table " + tableName + "(" + tableId + ")"; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new PreDeleteTable(namespaceId, tableId)), autoCleanup, goalMessage); break; } @@ -427,7 +427,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Online table " + tableId; final EnumSet expectedCurrStates = EnumSet.of(TableState.ONLINE, TableState.OFFLINE); - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>( new ChangeTableState(namespaceId, tableId, tableOp, expectedCurrStates)), autoCleanup, goalMessage); @@ -456,7 +456,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Offline table " + tableId; final EnumSet expectedCurrStates = EnumSet.of(TableState.ONLINE, TableState.OFFLINE); - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>( new ChangeTableState(namespaceId, tableId, tableOp, expectedCurrStates)), autoCleanup, goalMessage); @@ -492,7 +492,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat startRowStr, endRowStr); goalMessage += "Merge table " + tableName + "(" + tableId + ") splits from " + startRowStr + " to " + endRowStr; - manager.fate(type).seedTransaction(op, fateId, new TraceRepo<>( + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>( new TableRangeOp(MergeInfo.Operation.MERGE, namespaceId, tableId, startRow, endRow)), autoCleanup, goalMessage); break; @@ -524,7 +524,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Delete table " + tableName + "(" + tableId + ") range " + startRow + " to " + endRow; - manager.fate(type).seedTransaction(op, fateId, new TraceRepo<>( + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>( new TableRangeOp(MergeInfo.Operation.DELETE, namespaceId, tableId, startRow, endRow)), autoCleanup, goalMessage); break; @@ -550,7 +550,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Compact table (" + tableId + ") with config " + compactionConfig; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new CompactRange(namespaceId, tableId, compactionConfig)), autoCleanup, goalMessage); break; @@ -574,7 +574,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Cancel compaction of table (" + tableId + ")"; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new CancelCompactions(namespaceId, tableId)), autoCleanup, goalMessage); break; } @@ -609,7 +609,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Import table with new name: " + tableName + " from " + exportDirs; - manager.fate(type) + manager.fateClient(type) .seedTransaction(op, fateId, new TraceRepo<>(new ImportTable(c.getPrincipal(), tableName, exportDirs, namespaceId, keepMappings, keepOffline)), autoCleanup, goalMessage); @@ -639,7 +639,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage += "Export table " + tableName + "(" + tableId + ") to " + exportDir; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new ExportTable(namespaceId, tableName, tableId, exportDir)), autoCleanup, goalMessage); break; @@ -676,7 +676,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat manager.updateBulkImportStatus(dir, BulkImportState.INITIAL); goalMessage += "Bulk import (v2) " + dir + " to " + tableName + "(" + tableId + ")"; - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new ComputeBulkRange(tableId, dir, setTime)), autoCleanup, goalMessage); break; } @@ -720,7 +720,7 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat goalMessage += "Set availability for table: " + tableName + "(" + tableId + ") range: " + tRange + " to: " + tabletAvailability.name(); - manager.fate(type).seedTransaction(op, fateId, + manager.fateClient(type).seedTransaction(op, fateId, new TraceRepo<>(new LockTable(tableId, namespaceId, tRange, tabletAvailability)), autoCleanup, goalMessage); break; @@ -794,8 +794,8 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, TFat } goalMessage = "Splitting " + extent + " for user into " + (splits.size() + 1) + " tablets"; - manager.fate(type).seedTransaction(op, fateId, new PreSplit(extent, splits), autoCleanup, - goalMessage); + manager.fateClient(type).seedTransaction(op, fateId, new PreSplit(extent, splits), + autoCleanup, goalMessage); break; } default: @@ -847,9 +847,9 @@ public String waitForFateOperation(TInfo tinfo, TCredentials credentials, TFateI FateId fateId = FateId.fromThrift(opid); FateInstanceType type = fateId.getType(); - TStatus status = manager.fate(type).waitForCompletion(fateId); + TStatus status = manager.fateClient(type).waitForCompletion(fateId); if (status == TStatus.FAILED) { - Exception e = manager.fate(type).getException(fateId); + Exception e = manager.fateClient(type).getException(fateId); if (e instanceof ThriftTableOperationException) { throw (ThriftTableOperationException) e; } else if (e instanceof ThriftSecurityException) { @@ -861,7 +861,7 @@ public String waitForFateOperation(TInfo tinfo, TCredentials credentials, TFateI } } - String ret = manager.fate(type).getReturn(fateId); + String ret = manager.fateClient(type).getReturn(fateId); if (ret == null) { ret = ""; // thrift does not like returning null } @@ -873,7 +873,7 @@ public void finishFateOperation(TInfo tinfo, TCredentials credentials, TFateId o throws ThriftSecurityException { authenticate(credentials); FateId fateId = FateId.fromThrift(opid); - manager.fate(fateId.getType()).delete(fateId); + manager.fateClient(fateId.getType()).delete(fateId); } protected void authenticate(TCredentials credentials) throws ThriftSecurityException { @@ -987,6 +987,6 @@ public boolean cancelFateOperation(TInfo tinfo, TCredentials credentials, TFateI SecurityErrorCode.PERMISSION_DENIED); } - return manager.fate(fateId.getType()).cancel(fateId); + return manager.fateClient(fateId.getType()).cancel(fateId); } } diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java index 99caaf54d81..153857a6ebf 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java @@ -68,8 +68,10 @@ import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateCleaner; +import org.apache.accumulo.core.fate.FateClient; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.user.UserFateStore; import org.apache.accumulo.core.fate.zookeeper.MetaFateStore; @@ -108,8 +110,10 @@ import org.apache.accumulo.core.util.time.SteadyTime; import org.apache.accumulo.core.zookeeper.ZcStat; import org.apache.accumulo.manager.compaction.coordinator.CompactionCoordinator; +import org.apache.accumulo.manager.fate.FateManager; import org.apache.accumulo.manager.merge.FindMergeableRangeTask; import org.apache.accumulo.manager.metrics.ManagerMetrics; +import org.apache.accumulo.manager.metrics.fate.FateExecutorMetricsProducer; import org.apache.accumulo.manager.recovery.RecoveryManager; import org.apache.accumulo.manager.split.FileRangeCache; import org.apache.accumulo.manager.split.Splitter; @@ -144,6 +148,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.Comparators; import com.google.common.collect.ImmutableSortedMap; @@ -204,8 +209,12 @@ public class Manager extends AbstractServer implements LiveTServerSet.Listener, // should already have been set; ConcurrentHashMap will guarantee that all threads will see // the initialized fate references after the latch is ready private final CountDownLatch fateReadyLatch = new CountDownLatch(1); + private final AtomicReference>> fateClients = + new AtomicReference<>(); private final AtomicReference>> fateRefs = new AtomicReference<>(); + private volatile FateManager fateManager; + private volatile ManagerAssistant assitantManager; private final ManagerMetrics managerMetrics = new ManagerMetrics(); @@ -294,17 +303,7 @@ public boolean stillManager() { return getManagerState() != ManagerState.STOP; } - /** - * Retrieve the Fate object, blocking until it is ready. This could cause problems if Fate - * operations are attempted to be used prior to the Manager being ready for them. If these - * operations are triggered by a client side request from a tserver or client, it should be safe - * to wait to handle those until Fate is ready, but if it occurs during an upgrade, or some other - * time in the Manager before Fate is started, that may result in a deadlock and will need to be - * fixed. - * - * @return the Fate object, only after the fate components are running and ready - */ - public Fate fate(FateInstanceType type) { + private void waitForFate() { try { // block up to 30 seconds until it's ready; if it's still not ready, introduce some logging if (!fateReadyLatch.await(30, SECONDS)) { @@ -325,7 +324,28 @@ public Fate fate(FateInstanceType type) { Thread.currentThread().interrupt(); throw new IllegalStateException("Thread was interrupted; cannot proceed"); } - return getFateRefs().get(type); + } + + /** + * Retrieve the Fate object, blocking until it is ready. This could cause problems if Fate + * operations are attempted to be used prior to the Manager being ready for them. If these + * operations are triggered by a client side request from a tserver or client, it should be safe + * to wait to handle those until Fate is ready, but if it occurs during an upgrade, or some other + * time in the Manager before Fate is started, that may result in a deadlock and will need to be + * fixed. + * + * @return the Fate object, only after the fate components are running and ready + */ + public Fate fate(FateInstanceType type) { + waitForFate(); + var fate = Objects.requireNonNull(fateRefs.get(), "fateRefs is not set yet").get(type); + return Objects.requireNonNull(fate, () -> "fate type " + type + " is not present"); + } + + public FateClient fateClient(FateInstanceType type) { + waitForFate(); + var client = Objects.requireNonNull(fateClients.get(), "fateClients is not set yet").get(type); + return Objects.requireNonNull(client, () -> "fate client type " + type + " is not present"); } static final boolean X = true; @@ -565,7 +585,7 @@ public Splitter getSplitter() { } @Override - public FileRangeCache getSplitFileCache() { + public FileRangeCache getFileRangeCache() { return fileRangeCache; } @@ -694,9 +714,7 @@ public void run() { case CLEAN_STOP: switch (getManagerState()) { case NORMAL: - // USER fate stores its data in a user table and its operations may interact with - // all tables, need to completely shut it down before unloading user tablets - fate(FateInstanceType.USER).shutdown(1, MINUTES); + fateManager.stop(Duration.ofMinutes(1)); setManagerState(ManagerState.SAFE_MODE); break; case SAFE_MODE: { @@ -928,7 +946,7 @@ public void run() { // Start the Manager's Fate Service fateServiceHandler = new FateServiceHandler(this); managerClientHandler = new ManagerClientServiceHandler(this); - compactionCoordinator = new CompactionCoordinator(this, fateRefs); + compactionCoordinator = new CompactionCoordinator(this, this::fateClient); var processor = ThriftProcessorTypes.getManagerTProcessor(this, fateServiceHandler, compactionCoordinator.getThriftService(), managerClientHandler, getContext()); @@ -942,6 +960,22 @@ public void run() { throw new IllegalStateException("Unable to start server on host " + getBindAddress(), e); } + tserverSet.startListeningForTabletServerChanges(this); + + MetricsInfo metricsInfo = getContext().getMetricsInfo(); + + // Start manager assistant before getting lock, this allows non primary manager processes to + // work on stuff. + var shutdownComplete = getShutdownComplete(); + assitantManager = new ManagerAssistant(getContext(), getBindAddress(), tserverSet, + this::createFateInstance, shutdownComplete::get); + assitantManager.start(); + metricsInfo + .addMetricsProducers(assitantManager.getMetricsProducers().toArray(new MetricsProducer[0])); + + metricsInfo.init(MetricsInfo.serviceTags(getContext().getInstanceName(), getApplicationName(), + getAdvertiseAddress(), getResourceGroup())); + // block until we can obtain the ZK lock for the manager. Create the // initial lock using ThriftService.NONE. This will allow the lock // allocation to occur, but prevent any services from getting the @@ -977,7 +1011,6 @@ public void run() { Thread statusThread = Threads.createCriticalThread("Status Thread", new StatusThread()); statusThread.start(); - tserverSet.startListeningForTabletServerChanges(this); try { blockForTservers(); } catch (InterruptedException ex) { @@ -1002,9 +1035,7 @@ public void process(WatchedEvent event) { throw new IllegalStateException("Unable to read " + Constants.ZRECOVERY, e); } - MetricsInfo metricsInfo = getContext().getMetricsInfo(); - List producers = new ArrayList<>(); - producers.add(balanceManager.getMetrics()); + metricsInfo.addMetricsProducers(balanceManager.getMetrics()); final TabletGroupWatcher userTableTGW = new TabletGroupWatcher(this, this.userTabletStore, null, managerMetrics) { @@ -1126,29 +1157,14 @@ boolean canSuspendTablets() { this.splitter.start(); this.fileRangeCache = new FileRangeCache(context); - try { - Predicate isLockHeld = - lock -> ServiceLock.isLockHeld(context.getZooCache(), lock); - var metaInstance = initializeFateInstance(context, - new MetaFateStore<>(context.getZooSession(), managerLock.getLockID(), isLockHeld)); - var userInstance = initializeFateInstance(context, new UserFateStore<>(context, - SystemTables.FATE.tableName(), managerLock.getLockID(), isLockHeld)); + setupFate(context, metricsInfo); - if (!fateRefs.compareAndSet(null, - Map.of(FateInstanceType.META, metaInstance, FateInstanceType.USER, userInstance))) { - throw new IllegalStateException( - "Unexpected previous fate reference map already initialized"); - } - managerMetrics.configureFateMetrics(getConfiguration(), this, fateRefs.get()); - fateReadyLatch.countDown(); - } catch (KeeperException | InterruptedException e) { - throw new IllegalStateException("Exception setting up FaTE cleanup thread", e); - } + fateManager = new FateManager(getContext()); + fateManager.start(); + fateClient(FateInstanceType.USER).setSeedingConsumer(fateManager::notifySeeded); - producers.addAll(managerMetrics.getProducers(this)); - metricsInfo.addMetricsProducers(producers.toArray(new MetricsProducer[0])); - metricsInfo.init(MetricsInfo.serviceTags(getContext().getInstanceName(), getApplicationName(), - getAdvertiseAddress(), getResourceGroup())); + metricsInfo + .addMetricsProducers(managerMetrics.getProducers(this).toArray(new MetricsProducer[0])); ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor() .scheduleWithFixedDelay(() -> ScanServerMetadataEntries.clean(context), 10, 10, MINUTES)); @@ -1230,7 +1246,9 @@ boolean canSuspendTablets() { } log.debug("Shutting down fate."); - getFateRefs().keySet().forEach(type -> fate(type).close()); + fate(FateInstanceType.META).close(); + fateManager.stop(Duration.ZERO); + assitantManager.stop(); splitter.stop(); @@ -1274,16 +1292,56 @@ public void mainWait() throws InterruptedException { Thread.sleep(500); } - protected Fate initializeFateInstance(ServerContext context, FateStore store) { + /** + * This method exist so test can hook creating a fate instance. + */ + @VisibleForTesting + protected Fate createFateInstance(FateEnv env, FateStore store, + ServerContext context) { + return new Fate<>(env, store, true, TraceRepo::toLogString, getConfiguration(), + context.getScheduledExecutor()); + } - final Fate fateInstance = new Fate<>(this, store, true, TraceRepo::toLogString, - getConfiguration(), context.getScheduledExecutor()); + private void setupFate(ServerContext context, MetricsInfo metricsInfo) { + try { + Predicate isLockHeld = + lock -> ServiceLock.isLockHeld(context.getZooCache(), lock); + var metaStore = + new MetaFateStore(context.getZooSession(), managerLock.getLockID(), isLockHeld); + var metaInstance = createFateInstance(this, metaStore, context); + // configure this instance to process all data + metaInstance.setPartitions(Set.of(FatePartition.all(FateInstanceType.META))); + var userStore = new UserFateStore(context, SystemTables.FATE.tableName(), + managerLock.getLockID(), isLockHeld); + var userFateClient = new FateClient(userStore, TraceRepo::toLogString); + + var metaCleaner = new FateCleaner<>(metaStore, Duration.ofHours(8), this::getSteadyTime); + ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor() + .scheduleWithFixedDelay(metaCleaner::ageOff, 10, 4 * 60, MINUTES)); + var userCleaner = new FateCleaner<>(userStore, Duration.ofHours(8), this::getSteadyTime); + ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor() + .scheduleWithFixedDelay(userCleaner::ageOff, 10, 4 * 60, MINUTES)); + + if (!fateClients.compareAndSet(null, + Map.of(FateInstanceType.META, metaInstance, FateInstanceType.USER, userFateClient))) { + throw new IllegalStateException( + "Unexpected previous fateClient reference map already initialized"); + } + if (!fateRefs.compareAndSet(null, Map.of(FateInstanceType.META, metaInstance))) { + throw new IllegalStateException( + "Unexpected previous fate reference map already initialized"); + } - var fateCleaner = new FateCleaner<>(store, Duration.ofHours(8), this::getSteadyTime); - ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor() - .scheduleWithFixedDelay(fateCleaner::ageOff, 10, 4 * 60, MINUTES)); + managerMetrics.configureFateMetrics(getConfiguration(), this); + fateReadyLatch.countDown(); - return fateInstance; + var metaFateExecutorMetrics = new FateExecutorMetricsProducer(context, + fate(FateInstanceType.META).getFateExecutors(), + getConfiguration().getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL)); + metricsInfo.addMetricsProducers(metaFateExecutorMetrics); + } catch (KeeperException | InterruptedException e) { + throw new IllegalStateException("Exception setting up FaTE cleanup thread", e); + } } /** @@ -1635,12 +1693,6 @@ public void registerMetrics(MeterRegistry registry) { compactionCoordinator.registerMetrics(registry); } - private Map> getFateRefs() { - var fateRefs = this.fateRefs.get(); - Preconditions.checkState(fateRefs != null, "Unexpected null fate references map"); - return fateRefs; - } - @Override public ServiceLock getLock() { return managerLock; diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/ManagerAssistant.java b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerAssistant.java new file mode 100644 index 00000000000..4943599f353 --- /dev/null +++ b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerAssistant.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.manager; + +import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; + +import java.net.UnknownHostException; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +import org.apache.accumulo.core.client.admin.servers.ServerId; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.ResourceGroupId; +import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; +import org.apache.accumulo.core.fate.zookeeper.ZooUtil; +import org.apache.accumulo.core.lock.ServiceLock; +import org.apache.accumulo.core.lock.ServiceLockData; +import org.apache.accumulo.core.lock.ServiceLockPaths; +import org.apache.accumulo.core.lock.ServiceLockSupport; +import org.apache.accumulo.core.metrics.MetricsProducer; +import org.apache.accumulo.manager.fate.FateWorker; +import org.apache.accumulo.manager.fate.FateWorker.FateFactory; +import org.apache.accumulo.server.ServerContext; +import org.apache.accumulo.server.manager.LiveTServerSet; +import org.apache.accumulo.server.rpc.ServerAddress; +import org.apache.accumulo.server.rpc.TServerUtils; +import org.apache.accumulo.server.rpc.ThriftProcessorTypes; +import org.apache.thrift.TProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.net.HostAndPort; + +/** + * An assistant to the manager + */ +// FOLLOW_ON because this does not extend abstract server it does not get some of the benefits like +// monitoring of lock +public class ManagerAssistant { + + private static final Logger log = LoggerFactory.getLogger(ManagerAssistant.class); + private final ServerContext context; + private final String bindAddress; + private final LiveTServerSet liveTServerSet; + private final FateFactory fateFactory; + private final Supplier shutdownComplete; + private volatile ServiceLock managerWorkerLock; + private FateWorker fateWorker; + private ServerAddress thriftServer; + + protected ManagerAssistant(ServerContext context, String bindAddress, + LiveTServerSet liveTServerSet, FateFactory fateFactory, Supplier shutdownComplete) { + // Create another server context because the server context has the lock info and this class + // creates another lock separate from the manager lock. + // FOLLOW_ON creating another context instance in the process may cause problems, like + // duplicating some thread pools + this.context = new ServerContext(context.getSiteConfiguration()); + this.bindAddress = bindAddress; + this.liveTServerSet = liveTServerSet; + this.fateFactory = fateFactory; + this.shutdownComplete = shutdownComplete; + } + + public ServerContext getContext() { + return context; + } + + private ResourceGroupId getResourceGroup() { + return ResourceGroupId.DEFAULT; + } + + private HostAndPort startClientService() throws UnknownHostException { + fateWorker = new FateWorker(getContext(), liveTServerSet, fateFactory); + + // This class implements TabletClientService.Iface and then delegates calls. Be sure + // to set up the ThriftProcessor using this class, not the delegate. + TProcessor processor = + ThriftProcessorTypes.getManagerWorkerTProcessor(fateWorker, getContext()); + + thriftServer = TServerUtils.createThriftServer(getContext(), bindAddress, + Property.MANAGER_ASSISTANT_PORT, processor, this.getClass().getSimpleName(), + Property.MANAGER_ASSISTANT_PORTSEARCH, Property.MANAGER_ASSISTANT_MINTHREADS, + Property.MANAGER_ASSISTANT_MINTHREADS_TIMEOUT, Property.MANAGER_THREADCHECK); + thriftServer.startThriftServer("Thrift Manager Assistant Server"); + log.info("Starting {} Thrift server, listening on {}", this.getClass().getSimpleName(), + thriftServer.address); + return thriftServer.address; + } + + private void announceExistence(HostAndPort advertiseAddress) { + final ZooReaderWriter zoo = getContext().getZooSession().asReaderWriter(); + try { + + final ServiceLockPaths.ServiceLockPath zLockPath = getContext().getServerPaths() + .createManagerWorkerPath(getResourceGroup(), advertiseAddress); + ServiceLockSupport.createNonHaServiceLockPath(ServerId.Type.MANAGER_ASSISTANT, zoo, + zLockPath); + var serverLockUUID = UUID.randomUUID(); + managerWorkerLock = new ServiceLock(getContext().getZooSession(), zLockPath, serverLockUUID); + ServiceLock.LockWatcher lw = new ServiceLockSupport.ServiceLockWatcher( + ServerId.Type.MANAGER_ASSISTANT, shutdownComplete, + (type) -> getContext().getLowMemoryDetector().logGCInfo(getContext().getConfiguration())); + + for (int i = 0; i < 120 / 5; i++) { + zoo.putPersistentData(zLockPath.toString(), new byte[0], ZooUtil.NodeExistsPolicy.SKIP); + + ServiceLockData.ServiceDescriptors descriptors = new ServiceLockData.ServiceDescriptors(); + for (ServiceLockData.ThriftService svc : new ServiceLockData.ThriftService[] { + ServiceLockData.ThriftService.CLIENT, + ServiceLockData.ThriftService.MANAGER_ASSISTANT}) { + descriptors.addService(new ServiceLockData.ServiceDescriptor(serverLockUUID, svc, + advertiseAddress.toString(), this.getResourceGroup())); + } + + if (managerWorkerLock.tryLock(lw, new ServiceLockData(descriptors))) { + log.debug("Obtained manager assistant lock {}", managerWorkerLock.getLockPath()); + return; + } + log.info("Waiting for manager assistant lock"); + sleepUninterruptibly(5, TimeUnit.SECONDS); + } + String msg = "Too many retries, exiting."; + log.info(msg); + throw new RuntimeException(msg); + } catch (Exception e) { + log.info("Could not obtain manager assistant lock, exiting.", e); + throw new RuntimeException(e); + } + } + + public void start() { + HostAndPort advertiseAddress; + try { + advertiseAddress = startClientService(); + } catch (UnknownHostException e1) { + throw new RuntimeException("Failed to start the manager assistant client service", e1); + } + + announceExistence(advertiseAddress); + context.setServiceLock(getLock()); + fateWorker.setLock(getLock()); + } + + public void stop() { + thriftServer.server.stop(); + fateWorker.stop(); + } + + public ServiceLock getLock() { + return managerWorkerLock; + } + + public List getMetricsProducers() { + return fateWorker.getMetricsProducers(); + } +} diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/ManagerClientServiceHandler.java b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerClientServiceHandler.java index 6f8d284a240..38bbf54c04e 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/ManagerClientServiceHandler.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerClientServiceHandler.java @@ -59,6 +59,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent; import org.apache.accumulo.core.fate.Fate; +import org.apache.accumulo.core.fate.FateClient; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; @@ -67,6 +68,7 @@ import org.apache.accumulo.core.manager.thrift.ManagerGoalState; import org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo; import org.apache.accumulo.core.manager.thrift.ManagerState; +import org.apache.accumulo.core.manager.thrift.TEvent; import org.apache.accumulo.core.manager.thrift.TTabletMergeability; import org.apache.accumulo.core.manager.thrift.TabletLoadState; import org.apache.accumulo.core.manager.thrift.ThriftPropertyException; @@ -333,7 +335,7 @@ public void shutdownTabletServer(TInfo info, TCredentials c, String tabletServer } } - Fate fate = manager.fate(FateInstanceType.META); + FateClient fate = manager.fateClient(FateInstanceType.META); FateId fateId = fate.startTransaction(); String msg = "Shutdown tserver " + tabletServer; @@ -361,7 +363,7 @@ public void tabletServerStopping(TInfo tinfo, TCredentials credentials, String t if (manager.shutdownTServer(tserver)) { // If there is an exception seeding the fate tx this should cause the RPC to fail which should // cause the tserver to halt. Because of that not making an attempt to handle failure here. - Fate fate = manager.fate(FateInstanceType.META); + FateClient fate = manager.fateClient(FateInstanceType.META); var tid = fate.startTransaction(); String msg = "Shutdown tserver " + tabletServer; @@ -805,6 +807,18 @@ public long getManagerTimeNanos(TInfo tinfo, TCredentials credentials) return manager.getSteadyTime().getNanos(); } + @Override + public void processEvents(TInfo tinfo, TCredentials credentials, List tEvents) + throws TException { + if (!security.canPerformSystemActions(credentials)) { + throw new ThriftSecurityException(credentials.getPrincipal(), + SecurityErrorCode.PERMISSION_DENIED); + } + + manager.getEventCoordinator().events(tEvents.stream().map(EventCoordinator.Event::fromThrift) + .peek(event -> log.trace("remote event : {}", event)).iterator()); + } + protected TableId getTableId(ClientContext context, String tableName) throws ThriftTableOperationException { return ClientServiceHandler.checkTableId(context, tableName, null); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/CompactionCoordinator.java b/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/CompactionCoordinator.java index e6c0c86f2e5..d6915b5155c 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/CompactionCoordinator.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/CompactionCoordinator.java @@ -56,8 +56,8 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -90,6 +90,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent; import org.apache.accumulo.core.fate.Fate; +import org.apache.accumulo.core.fate.FateClient; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; @@ -121,7 +122,6 @@ import org.apache.accumulo.core.tabletserver.thrift.TCompactionKind; import org.apache.accumulo.core.tabletserver.thrift.TCompactionStats; import org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob; -import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.core.util.cache.Caches.CacheName; import org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams; import org.apache.accumulo.core.util.compaction.CompactionServicesConfig; @@ -271,7 +271,7 @@ static FailureCounts incrementSuccess(Object key, FailureCounts counts) { private final ServerContext ctx; private final AuditedSecurityOperation security; private final CompactionJobQueues jobQueues; - private final AtomicReference>> fateInstances; + private final Function> fateClients; // Exposed for tests protected final CountDownLatch shutdown = new CountDownLatch(1); @@ -291,7 +291,7 @@ static FailureCounts incrementSuccess(Object key, FailureCounts counts) { private final Set activeCompactorReservationRequest = ConcurrentHashMap.newKeySet(); public CompactionCoordinator(Manager manager, - AtomicReference>> fateInstances) { + Function> fateClients) { this.ctx = manager.getContext(); this.security = ctx.getSecurityOperation(); this.manager = Objects.requireNonNull(manager); @@ -303,7 +303,7 @@ public CompactionCoordinator(Manager manager, this.queueMetrics = new QueueMetrics(jobQueues); - this.fateInstances = fateInstances; + this.fateClients = fateClients; completed = ctx.getCaches().createNewBuilder(CacheName.COMPACTIONS_COMPLETED, true) .maximumSize(200).expireAfterWrite(10, TimeUnit.MINUTES).build(); @@ -326,7 +326,7 @@ public CompactionCoordinator(Manager manager, .maximumWeight(10485760L).weigher(weigher).build(); deadCompactionDetector = - new DeadCompactionDetector(this.ctx, this, ctx.getScheduledExecutor(), fateInstances); + new DeadCompactionDetector(this.ctx, this, ctx.getScheduledExecutor(), fateClients); var rootReservationPool = ThreadPools.getServerThreadPools().createExecutorService( ctx.getConfiguration(), Property.COMPACTION_COORDINATOR_RESERVATION_THREADS_ROOT, true); @@ -789,17 +789,9 @@ public void compactionCompleted(TInfo tinfo, TCredentials credentials, } // maybe fate has not started yet - var localFates = fateInstances.get(); - while (localFates == null) { - UtilWaitThread.sleep(100); - if (shutdown.getCount() == 0) { - return; - } - localFates = fateInstances.get(); - } - var extent = KeyExtent.fromThrift(textent); - var localFate = localFates.get(FateInstanceType.fromTableId(extent.tableId())); + var fateType = FateInstanceType.fromTableId(extent.tableId()); + var localFate = fateClients.apply(fateType); LOG.info("Compaction completed, id: {}, stats: {}, extent: {}", externalCompactionId, stats, extent); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/DeadCompactionDetector.java b/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/DeadCompactionDetector.java index da852f1bb1a..ce04296a615 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/DeadCompactionDetector.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/DeadCompactionDetector.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.manager.compaction.coordinator; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -27,14 +28,14 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; -import org.apache.accumulo.core.fate.Fate; +import org.apache.accumulo.core.fate.FateClient; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; import org.apache.accumulo.core.metadata.schema.Ample.DataLevel; @@ -62,16 +63,16 @@ public class DeadCompactionDetector { private final ScheduledThreadPoolExecutor schedExecutor; private final ConcurrentHashMap deadCompactions; private final Set tablesWithUnreferencedTmpFiles = new HashSet<>(); - private final AtomicReference>> fateInstances; + private final Function> fateClients; public DeadCompactionDetector(ServerContext context, CompactionCoordinator coordinator, ScheduledThreadPoolExecutor stpe, - AtomicReference>> fateInstances) { + Function> fateClients) { this.context = context; this.coordinator = coordinator; this.schedExecutor = stpe; this.deadCompactions = new ConcurrentHashMap<>(); - this.fateInstances = fateInstances; + this.fateClients = fateClients; } public void addTableId(TableId tableWithUnreferencedTmpFiles) { @@ -196,13 +197,8 @@ private void detectDeadCompactions() { if (!tabletCompactions.isEmpty()) { // look for any compactions committing in fate and remove those - var fateMap = fateInstances.get(); - if (fateMap == null) { - log.warn("Fate is not present, can not look for dead compactions"); - return; - } - try (Stream keyStream = fateMap.values().stream() - .flatMap(fate -> fate.list(FateKey.FateKeyType.COMPACTION_COMMIT))) { + try (Stream keyStream = Arrays.stream(FateInstanceType.values()).map(fateClients) + .flatMap(fateClient -> fateClient.list(FateKey.FateKeyType.COMPACTION_COMMIT))) { keyStream.map(fateKey -> fateKey.getCompactionId().orElseThrow()).forEach(ecid -> { if (tabletCompactions.remove(ecid) != null) { log.debug("Ignoring compaction {} that is committing in a fate", ecid); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateManager.java b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateManager.java new file mode 100644 index 00000000000..0fd9fb9b64e --- /dev/null +++ b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateManager.java @@ -0,0 +1,446 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.manager.fate; + +import static org.apache.accumulo.core.lock.ServiceLockPaths.ResourceGroupPredicate.DEFAULT_RG_ONLY; + +import java.time.Duration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.apache.accumulo.core.fate.FateId; +import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; +import org.apache.accumulo.core.fate.thrift.FateWorkerService; +import org.apache.accumulo.core.fate.user.UserFateStore; +import org.apache.accumulo.core.lock.ServiceLockPaths.AddressSelector; +import org.apache.accumulo.core.metadata.SystemTables; +import org.apache.accumulo.core.rpc.ThriftUtil; +import org.apache.accumulo.core.rpc.clients.ThriftClientTypes; +import org.apache.accumulo.core.trace.TraceUtil; +import org.apache.accumulo.core.util.CountDownTimer; +import org.apache.accumulo.core.util.threads.Threads; +import org.apache.accumulo.manager.tableOps.FateEnv; +import org.apache.accumulo.server.ServerContext; +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Range; +import com.google.common.collect.RangeMap; +import com.google.common.collect.Sets; +import com.google.common.collect.TreeRangeMap; +import com.google.common.net.HostAndPort; + +/** + * Partitions {@link FateInstanceType#USER} fate across manager assistant processes. This is done by + * assigning ranges of the fate uuid key space to different processes. The partitions are logical + * and do not correspond to the physical partitioning of the fate table. + * + *

+ * Does not currently manage {@link FateInstanceType#META} + *

+ */ +public class FateManager { + + private static final Logger log = LoggerFactory.getLogger(FateManager.class); + + private final ServerContext context; + + public FateManager(ServerContext context) { + this.context = context; + } + + private final AtomicBoolean stop = new AtomicBoolean(false); + + record FateHostPartition(HostAndPort hostPort, FatePartition partition) { + } + + private final AtomicReference> stableAssignments = + new AtomicReference<>(TreeRangeMap.create()); + + private final Map> pendingNotifications = new HashMap<>(); + + private void managerWorkers() throws TException, InterruptedException { + log.debug("Started Fate Manager"); + long stableCount = 0; + outer: while (!stop.get()) { + + long sleepTime = Math.min(stableCount * 100, 5_000); + Thread.sleep(sleepTime); + + // This map will contain all current workers even if their partitions are empty + Map currentPartitions; + try { + currentPartitions = getCurrentAssignments(); + } catch (TException e) { + log.warn("Failed to get current partitions ", e); + continue; + } + Map> currentAssignments = new HashMap<>(); + currentPartitions.forEach((k, v) -> currentAssignments.put(k, v.partitions())); + Set desiredParititions = getDesiredPartitions(currentAssignments.size()); + + Map> desired = + computeDesiredAssignments(currentAssignments, desiredParititions); + + if (desired.equals(currentAssignments)) { + RangeMap rangeMap = TreeRangeMap.create(); + currentAssignments.forEach((hostAndPort, partitions) -> { + partitions.forEach(partition -> { + rangeMap.put(Range.closed(partition.start(), partition.end()), + new FateHostPartition(hostAndPort, partition)); + }); + }); + stableAssignments.set(rangeMap); + stableCount++; + } else { + stableAssignments.set(TreeRangeMap.create()); + stableCount = 0; + } + + // are there any workers with extra partitions? If so need to unload those first. + int unloads = 0; + for (Map.Entry> entry : desired.entrySet()) { + HostAndPort worker = entry.getKey(); + Set partitions = entry.getValue(); + var curr = currentAssignments.getOrDefault(worker, Set.of()); + if (!Sets.difference(curr, partitions).isEmpty()) { + // This worker has extra partitions that are not desired + var intersection = Sets.intersection(curr, partitions); + if (!setWorkerPartitions(worker, currentPartitions.get(worker).updateId(), + intersection)) { + log.debug("Failed to set partitions for {} to {}", worker, intersection); + // could not set, so start completely over + continue outer; + } else { + log.debug("Set partitions for {} to {} from {}", worker, intersection, curr); + unloads++; + } + } + } + + if (unloads > 0) { + // some tablets were unloaded, so start over and get new update ids and the current + // partitions + continue outer; + } + + // Load all partitions on all workers.. + for (Map.Entry> entry : desired.entrySet()) { + HostAndPort worker = entry.getKey(); + Set partitions = entry.getValue(); + var curr = currentAssignments.getOrDefault(worker, Set.of()); + if (!curr.equals(partitions)) { + if (!setWorkerPartitions(worker, currentPartitions.get(worker).updateId(), partitions)) { + log.debug("Failed to set partitions for {} to {}", worker, partitions); + // could not set, so start completely over + continue outer; + } else { + log.debug("Set partitions for {} to {} from {}", worker, partitions, curr); + } + } + } + } + } + + private Thread assignmentThread = null; + private Thread ntfyThread = null; + + public synchronized void start() { + Preconditions.checkState(assignmentThread == null); + Preconditions.checkState(ntfyThread == null); + Preconditions.checkState(!stop.get()); + + assignmentThread = Threads.createCriticalThread("Fate Manager", () -> { + try { + managerWorkers(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + }); + assignmentThread.start(); + + ntfyThread = Threads.createCriticalThread("Fate Notify", new NotifyTask()); + ntfyThread.start(); + } + + public synchronized void stop(Duration timeout) { + if (!stop.compareAndSet(false, true)) { + return; + } + + var timer = CountDownTimer.startNew(timeout); + + try { + if (assignmentThread != null) { + assignmentThread.join(); + } + if (ntfyThread != null) { + ntfyThread.join(); + } + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + // Try to set every assistant manager to an empty set of partitions. This will cause them all to + // stop looking for work. + Map currentAssignments = null; + try { + currentAssignments = getCurrentAssignments(); + } catch (TException e) { + log.warn("Failed to get current assignments", e); + currentAssignments = Map.of(); + } + for (var entry : currentAssignments.entrySet()) { + var hostPort = entry.getKey(); + var currentPartitions = entry.getValue(); + if (!currentPartitions.partitions.isEmpty()) { + try { + setWorkerPartitions(hostPort, currentPartitions.updateId(), Set.of()); + } catch (TException e) { + log.warn("Failed to unassign fate partitions {}", hostPort, e); + } + } + } + + stableAssignments.set(TreeRangeMap.create()); + + if (!timer.isExpired()) { + var store = new UserFateStore(context, SystemTables.FATE.tableName(), null, null); + + var reserved = store.getActiveReservations(Set.of(FatePartition.all(FateInstanceType.USER))); + while (!reserved.isEmpty() && !timer.isExpired()) { + if (log.isTraceEnabled()) { + reserved.forEach((fateId, reservation) -> { + log.trace("In stop(), waiting on {} {} ", fateId, reservation); + }); + } + try { + Thread.sleep(Math.min(100, timer.timeLeft(TimeUnit.MILLISECONDS))); + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } + } + } + + /** + * Makes a best effort to notify this fate operation was seeded. + */ + public void notifySeeded(FateId fateId) { + var hostPartition = stableAssignments.get().get(fateId); + if (hostPartition != null) { + synchronized (pendingNotifications) { + pendingNotifications.computeIfAbsent(hostPartition.hostPort(), k -> new HashSet<>()) + .add(hostPartition.partition()); + pendingNotifications.notify(); + } + } + } + + private class NotifyTask implements Runnable { + + @Override + public void run() { + while (!stop.get()) { + try { + Map> copy; + synchronized (pendingNotifications) { + if (pendingNotifications.isEmpty()) { + pendingNotifications.wait(100); + } + copy = Map.copyOf(pendingNotifications); + pendingNotifications.clear(); + } + + for (var entry : copy.entrySet()) { + HostAndPort address = entry.getKey(); + Set partitions = entry.getValue(); + FateWorkerService.Client client = + ThriftUtil.getClient(ThriftClientTypes.FATE_WORKER, address, context); + try { + log.trace("Notifying about seeding {} {}", address, partitions); + client.seeded(TraceUtil.traceInfo(), context.rpcCreds(), + partitions.stream().map(FatePartition::toThrift).toList()); + } finally { + ThriftUtil.returnClient(client, context); + } + } + + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } catch (TException e) { + log.warn("Failed to send notification that fate was seeded", e); + } + } + } + } + + /** + * Sets the complete set of partitions a server should work on. It will only succeed if the update + * id is valid. The update id avoids race conditions w/ previously queued network messages, it's a + * distributed compare and set mechanism that can detect changes. + * + * @param address The server to set partitions on + * @param updateId What we think the servers current set of fate partitions are. + * @param desired The new set of fate partitions this server should start working. It should only + * work on these and nothing else. + * @return true if the partitions were set false if they were not set. + */ + private boolean setWorkerPartitions(HostAndPort address, long updateId, + Set desired) throws TException { + FateWorkerService.Client client = + ThriftUtil.getClient(ThriftClientTypes.FATE_WORKER, address, context); + try { + log.trace("Setting partitions {} {}", address, desired); + var result = client.setPartitions(TraceUtil.traceInfo(), context.rpcCreds(), updateId, + desired.stream().map(FatePartition::toThrift).toList()); + return result; + } finally { + ThriftUtil.returnClient(client, context); + } + } + + /** + * Compute the desired distribution of partitions across workers. Favors leaving partitions in + * place if possible. + */ + private Map> computeDesiredAssignments( + Map> currentAssignments, + Set desiredParititions) { + + Preconditions.checkArgument(currentAssignments.size() == desiredParititions.size()); + Map> desiredAssignments = new HashMap<>(); + + var copy = new HashSet<>(desiredParititions); + + currentAssignments.forEach((hp, partitions) -> { + if (!partitions.isEmpty()) { + var firstPart = partitions.iterator().next(); + if (copy.contains(firstPart)) { + desiredAssignments.put(hp, Set.of(firstPart)); + copy.remove(firstPart); + } + } + }); + + var iter = copy.iterator(); + currentAssignments.forEach((hp, partitions) -> { + if (!desiredAssignments.containsKey(hp)) { + desiredAssignments.put(hp, Set.of(iter.next())); + } + }); + + if (log.isTraceEnabled()) { + log.trace("Logging desired partitions"); + desiredAssignments.forEach((hp, parts) -> { + log.trace(" desired {} {} {}", hp, parts.size(), parts); + }); + } + + return desiredAssignments; + } + + /** + * Computes a single partition for each worker such that the partition cover all possible UUIDs + * and evenly divide the UUIDs. + */ + private Set getDesiredPartitions(int numWorkers) { + Preconditions.checkArgument(numWorkers >= 0); + + if (numWorkers == 0) { + return Set.of(); + } + + // create a single partition per worker that equally divides the space + HashSet desired = new HashSet<>(); + // All the shifting is because java does not have unsigned integers. Want to evenly partition + // [0,2^64) into numWorker ranges, but can not directly do that. Work w/ 60 bit unsigned + // integers to partition the space and then shift over by 4. Used 60 bits instead of 63 so it + // nicely aligns w/ hex in the uuid. + long jump = ((1L << 60)) / numWorkers; + for (int i = 0; i < numWorkers - 1; i++) { + long start = (i * jump) << 4; + long end = ((i + 1) * jump) << 4; + + UUID startUuid = new UUID(start, 0); + UUID endUuid = new UUID(end, 0); + + desired.add(new FatePartition(FateId.from(FateInstanceType.USER, startUuid), + FateId.from(FateInstanceType.USER, endUuid))); + } + + long start = ((numWorkers - 1) * jump) << 4; + UUID startUuid = new UUID(start, 0); + // last partition has a special end uuid that is all f nibbles. + UUID endUuid = new UUID(-1, -1); + desired.add(new FatePartition(FateId.from(FateInstanceType.USER, startUuid), + FateId.from(FateInstanceType.USER, endUuid))); + + return desired; + } + + // The updateId accomplishes two things. First it ensures that setting partition RPC can only + // execute once on the server side. Second when a new update id is requested it cancels any + // outstanding RPCs to set partitions that have not executed yet. + record CurrentPartitions(long updateId, Set partitions) { + } + + private Map getCurrentAssignments() throws TException { + var workers = + context.getServerPaths().getManagerWorker(DEFAULT_RG_ONLY, AddressSelector.all(), true); + + log.trace("getting current assignments from {}", workers); + + Map currentAssignments = new HashMap<>(); + + for (var worker : workers) { + var address = HostAndPort.fromString(worker.getServer()); + + FateWorkerService.Client client = + ThriftUtil.getClient(ThriftClientTypes.FATE_WORKER, address, context); + try { + + var tparitions = client.getPartitions(TraceUtil.traceInfo(), context.rpcCreds()); + var partitions = + tparitions.partitions.stream().map(FatePartition::from).collect(Collectors.toSet()); + currentAssignments.put(address, new CurrentPartitions(tparitions.updateId, partitions)); + } finally { + ThriftUtil.returnClient(client, context); + } + } + + if (log.isTraceEnabled()) { + log.trace("Logging current assignments"); + currentAssignments.forEach((hostPort, partitions) -> { + log.trace("current assignment {} {}", hostPort, partitions); + }); + } + + return currentAssignments; + } +} diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorker.java b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorker.java new file mode 100644 index 00000000000..61e356c7b7b --- /dev/null +++ b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorker.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.manager.fate; + +import static org.apache.accumulo.core.util.LazySingletons.RANDOM; + +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode; +import org.apache.accumulo.core.clientImpl.thrift.TInfo; +import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.fate.Fate; +import org.apache.accumulo.core.fate.FatePartition; +import org.apache.accumulo.core.fate.FateStore; +import org.apache.accumulo.core.fate.thrift.FateWorkerService; +import org.apache.accumulo.core.fate.thrift.TFatePartition; +import org.apache.accumulo.core.fate.thrift.TFatePartitions; +import org.apache.accumulo.core.fate.user.UserFateStore; +import org.apache.accumulo.core.fate.zookeeper.ZooUtil; +import org.apache.accumulo.core.lock.ServiceLock; +import org.apache.accumulo.core.metadata.SystemTables; +import org.apache.accumulo.core.metrics.MetricsProducer; +import org.apache.accumulo.core.securityImpl.thrift.TCredentials; +import org.apache.accumulo.manager.metrics.fate.FateExecutorMetricsProducer; +import org.apache.accumulo.manager.tableOps.FateEnv; +import org.apache.accumulo.server.ServerContext; +import org.apache.accumulo.server.manager.LiveTServerSet; +import org.apache.accumulo.server.security.AuditedSecurityOperation; +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +public class FateWorker implements FateWorkerService.Iface { + + private static final Logger log = LoggerFactory.getLogger(FateWorker.class); + private final ServerContext context; + private final AuditedSecurityOperation security; + private final LiveTServerSet liveTserverSet; + private final FateFactory fateFactory; + private Fate fate; + private FateWorkerEnv fateWorkerEnv; + + public interface FateFactory { + Fate create(FateEnv env, FateStore store, ServerContext context); + } + + public FateWorker(ServerContext ctx, LiveTServerSet liveTServerSet, FateFactory fateFactory) { + this.context = ctx; + this.security = ctx.getSecurityOperation(); + this.fate = null; + this.liveTserverSet = liveTServerSet; + this.fateFactory = fateFactory; + } + + public synchronized void setLock(ServiceLock lock) { + fateWorkerEnv = new FateWorkerEnv(context, lock, liveTserverSet); + Predicate isLockHeld = l -> ServiceLock.isLockHeld(context.getZooCache(), l); + UserFateStore store = + new UserFateStore<>(context, SystemTables.FATE.tableName(), lock.getLockID(), isLockHeld); + this.fate = fateFactory.create(fateWorkerEnv, store, context); + } + + private Long expectedUpdateId = null; + + @Override + public TFatePartitions getPartitions(TInfo tinfo, TCredentials credentials) + throws ThriftSecurityException { + if (!security.canPerformSystemActions(credentials)) { + throw new AccumuloSecurityException(credentials.getPrincipal(), + SecurityErrorCode.PERMISSION_DENIED).asThriftException(); + } + + // generate a new one time use update id + long updateId = RANDOM.get().nextLong(); + + // Getting the partitions and setting the new update id must be mutually exclusive with any + // updates of the partitions concurrently executing. This ensures the new update id goes with + // the current partitions returned. + synchronized (this) { + // invalidate any queued partitions update that have not executed yet and set the new update + // id + expectedUpdateId = updateId; + + if (fate == null) { + return new TFatePartitions(updateId, List.of()); + } else { + return new TFatePartitions(updateId, + fate.getPartitions().stream().map(FatePartition::toThrift).toList()); + } + } + } + + @Override + public boolean setPartitions(TInfo tinfo, TCredentials credentials, long updateId, + List desired) throws ThriftSecurityException { + if (!security.canPerformSystemActions(credentials)) { + throw new AccumuloSecurityException(credentials.getPrincipal(), + SecurityErrorCode.PERMISSION_DENIED).asThriftException(); + } + + synchronized (this) { + if (fate != null && expectedUpdateId != null && updateId == expectedUpdateId) { + // Set to null which makes it so that an update id can only be used once. + expectedUpdateId = null; + var desiredSet = desired.stream().map(FatePartition::from).collect(Collectors.toSet()); + var oldPartitions = fate.setPartitions(desiredSet); + log.info("Changed partitions from {} to {}", oldPartitions, desiredSet); + return true; + } else { + log.debug( + "Did not change partitions to {} expectedUpdateId:{} updateId:{} localFate==null:{}", + desired, expectedUpdateId, updateId, fate == null); + return false; + } + } + } + + @Override + public void seeded(TInfo tinfo, TCredentials credentials, List tpartitions) + throws TException { + + if (!security.canPerformSystemActions(credentials)) { + throw new AccumuloSecurityException(credentials.getPrincipal(), + SecurityErrorCode.PERMISSION_DENIED).asThriftException(); + } + + Fate localFate; + synchronized (this) { + localFate = fate; + } + + if (localFate != null) { + localFate.seeded(tpartitions.stream().map(FatePartition::from).collect(Collectors.toSet())); + } + } + + public synchronized void stop() { + fate.shutdown(1, TimeUnit.MINUTES); + fate.close(); + fateWorkerEnv.stop(); + fate = null; + fateWorkerEnv = null; + } + + public synchronized List getMetricsProducers() { + Preconditions.checkState(fate != null, "Not started yet"); + return List.of(new FateExecutorMetricsProducer(context, fate.getFateExecutors(), context + .getConfiguration().getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL))); + + } +} diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorkerEnv.java b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorkerEnv.java new file mode 100644 index 00000000000..2cbad172eb5 --- /dev/null +++ b/server/manager/src/main/java/org/apache/accumulo/manager/fate/FateWorkerEnv.java @@ -0,0 +1,244 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.manager.fate; + +import static org.apache.accumulo.core.util.threads.ThreadPoolNames.FILE_RENAME_POOL; + +import java.util.Collection; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.accumulo.core.client.AccumuloException; +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.TableId; +import org.apache.accumulo.core.dataImpl.KeyExtent; +import org.apache.accumulo.core.lock.ServiceLock; +import org.apache.accumulo.core.manager.thrift.BulkImportState; +import org.apache.accumulo.core.metadata.TServerInstance; +import org.apache.accumulo.core.metadata.schema.Ample; +import org.apache.accumulo.core.metadata.schema.ExternalCompactionId; +import org.apache.accumulo.core.rpc.ThriftUtil; +import org.apache.accumulo.core.rpc.clients.ThriftClientTypes; +import org.apache.accumulo.core.trace.TraceUtil; +import org.apache.accumulo.core.util.threads.ThreadPools; +import org.apache.accumulo.core.util.threads.Threads; +import org.apache.accumulo.core.util.time.SteadyTime; +import org.apache.accumulo.manager.EventCoordinator; +import org.apache.accumulo.manager.EventPublisher; +import org.apache.accumulo.manager.EventQueue; +import org.apache.accumulo.manager.split.FileRangeCache; +import org.apache.accumulo.manager.tableOps.FateEnv; +import org.apache.accumulo.server.ServerContext; +import org.apache.accumulo.server.fs.VolumeManager; +import org.apache.accumulo.server.manager.LiveTServerSet; +import org.apache.accumulo.server.tables.TableManager; +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FateWorkerEnv implements FateEnv { + + private static final Logger log = LoggerFactory.getLogger(FateWorkerEnv.class); + + private final ServerContext ctx; + private final ExecutorService refreshPool; + private final ExecutorService renamePool; + private final ServiceLock serviceLock; + private final FileRangeCache fileRangeCache; + private final EventHandler eventHandler; + private final LiveTServerSet liveTServerSet; + + private final EventQueue queue = new EventQueue(); + private final AtomicBoolean stopped = new AtomicBoolean(false); + private final Thread eventSendThread; + + public void stop() { + stopped.set(true); + try { + eventSendThread.join(); + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } + + private class EventSender implements Runnable { + @Override + public void run() { + while (!stopped.get()) { + try { + var events = queue.poll(100, TimeUnit.MILLISECONDS); + if (events.isEmpty()) { + continue; + } + + var tEvents = events.stream().map(EventCoordinator.Event::toThrift).toList(); + + var client = ThriftClientTypes.MANAGER.getConnection(ctx); + try { + if (client != null) { + client.processEvents(TraceUtil.traceInfo(), ctx.rpcCreds(), tEvents); + } + } catch (TException e) { + log.warn("Failed to send events to manager", e); + } finally { + if (client != null) { + ThriftUtil.close(client, ctx); + } + } + + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } + } + } + + private class EventHandler implements EventPublisher { + + @Override + public void event(String msg, Object... args) { + log.info(String.format(msg, args)); + queue.add(new EventCoordinator.Event()); + } + + @Override + public void event(Ample.DataLevel level, String msg, Object... args) { + log.info(String.format(msg, args)); + queue.add(new EventCoordinator.Event(level)); + } + + @Override + public void event(TableId tableId, String msg, Object... args) { + log.info(String.format(msg, args)); + queue.add(new EventCoordinator.Event(tableId)); + } + + @Override + public void event(KeyExtent extent, String msg, Object... args) { + log.debug(String.format(msg, args)); + queue.add(new EventCoordinator.Event(extent)); + } + + @Override + public void event(Collection extents, String msg, Object... args) { + if (!extents.isEmpty()) { + log.debug(String.format(msg, args)); + extents.forEach(extent -> queue.add(new EventCoordinator.Event(extent))); + } + } + } + + FateWorkerEnv(ServerContext ctx, ServiceLock lock, LiveTServerSet liveTserverSet) { + this.ctx = ctx; + this.refreshPool = ThreadPools.getServerThreadPools().getPoolBuilder("Tablet refresh ") + .numCoreThreads(ctx.getConfiguration().getCount(Property.MANAGER_TABLET_REFRESH_MINTHREADS)) + .numMaxThreads(ctx.getConfiguration().getCount(Property.MANAGER_TABLET_REFRESH_MAXTHREADS)) + .build(); + int poolSize = ctx.getConfiguration().getCount(Property.MANAGER_RENAME_THREADS); + // FOLLOW_ON this import table name is not correct for the thread pool name, fix in stand alone + // PR + this.renamePool = ThreadPools.getServerThreadPools().getPoolBuilder(FILE_RENAME_POOL.poolName) + .numCoreThreads(poolSize).build(); + this.serviceLock = lock; + this.fileRangeCache = new FileRangeCache(ctx); + this.eventHandler = new EventHandler(); + this.liveTServerSet = liveTserverSet; + + eventSendThread = Threads.createCriticalThread("Fate Worker Event Sender", new EventSender()); + eventSendThread.start(); + } + + @Override + public ServerContext getContext() { + return ctx; + } + + @Override + public EventPublisher getEventPublisher() { + return eventHandler; + } + + @Override + public void recordCompactionCompletion(ExternalCompactionId ecid) { + // FOLLOW_ON This data is stored in memory on the manager. This entire feature needs to be + // examined and potentially reworked. One solution would be to send an RPC to the manager to + // update it's in memory state. A better solution would be to move away from in memory state + // that is lost when the manager restarts. + } + + @Override + public Set onlineTabletServers() { + return liveTServerSet.getSnapshot().getTservers(); + } + + @Override + public TableManager getTableManager() { + return ctx.getTableManager(); + } + + @Override + public VolumeManager getVolumeManager() { + return ctx.getVolumeManager(); + } + + @Override + public void updateBulkImportStatus(String string, BulkImportState bulkImportState) { + // FOLLOW_ON This data is stored in memory on the manager. This entire feature needs to be + // examined and potentially reworked. One solution would be to send an RPC to the manager to + // update it's in memory state. A better solution would be to move away from in memory state + // that is lost when the manager restarts. + } + + @Override + public void removeBulkImportStatus(String sourceDir) { + // FOLLOW_ON + } + + @Override + public ServiceLock getServiceLock() { + return serviceLock; + } + + @Override + public SteadyTime getSteadyTime() { + try { + return SteadyTime.from(ctx.instanceOperations().getManagerTime()); + } catch (AccumuloException | AccumuloSecurityException e) { + throw new IllegalStateException(e); + } + } + + @Override + public ExecutorService getTabletRefreshThreadPool() { + return refreshPool; + } + + @Override + public FileRangeCache getFileRangeCache() { + return fileRangeCache; + } + + @Override + public ExecutorService getRenamePool() { + return renamePool; + } +} diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/merge/FindMergeableRangeTask.java b/server/manager/src/main/java/org/apache/accumulo/manager/merge/FindMergeableRangeTask.java index e4b39229ef1..e5e8c850725 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/merge/FindMergeableRangeTask.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/merge/FindMergeableRangeTask.java @@ -158,7 +158,7 @@ void submit(MergeableRange range, FateInstanceType type, Entry t tableId, startRowStr, endRowStr); var fateKey = FateKey.forMerge(new KeyExtent(tableId, range.endRow, range.startRow)); - manager.fate(type).seedTransaction(FateOperation.SYSTEM_MERGE, fateKey, + manager.fateClient(type).seedTransaction(FateOperation.SYSTEM_MERGE, fateKey, new TraceRepo<>( new TableRangeOp(Operation.SYSTEM_MERGE, namespaceId, tableId, startRow, endRow)), true); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/ManagerMetrics.java b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/ManagerMetrics.java index 77689cea028..9e6f9c4f2dd 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/ManagerMetrics.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/ManagerMetrics.java @@ -27,14 +27,11 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.fate.Fate; -import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.manager.thrift.ManagerGoalState; import org.apache.accumulo.core.metadata.schema.Ample.DataLevel; import org.apache.accumulo.core.metrics.MetricsProducer; @@ -42,7 +39,6 @@ import org.apache.accumulo.manager.metrics.fate.FateMetrics; import org.apache.accumulo.manager.metrics.fate.meta.MetaFateMetrics; import org.apache.accumulo.manager.metrics.fate.user.UserFateMetrics; -import org.apache.accumulo.manager.tableOps.FateEnv; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; @@ -66,17 +62,14 @@ public void updateManagerGoalState(ManagerGoalState goal) { goalState.set(newValue); } - public void configureFateMetrics(final AccumuloConfiguration conf, final Manager manager, - Map> fateRefs) { + public void configureFateMetrics(final AccumuloConfiguration conf, final Manager manager) { requireNonNull(conf, "AccumuloConfiguration must not be null"); requireNonNull(conf, "Manager must not be null"); fateMetrics = List.of( new MetaFateMetrics(manager.getContext(), - conf.getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL), - fateRefs.get(FateInstanceType.META).getFateExecutors()), + conf.getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL)), new UserFateMetrics(manager.getContext(), - conf.getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL), - fateRefs.get(FateInstanceType.USER).getFateExecutors())); + conf.getTimeInMillis(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL))); } public void incrementTabletGroupWatcherError(DataLevel level) { diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateExecutorMetricsProducer.java b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateExecutorMetricsProducer.java new file mode 100644 index 00000000000..43b8508c410 --- /dev/null +++ b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateExecutorMetricsProducer.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.manager.metrics.fate; + +import static org.apache.accumulo.manager.metrics.fate.FateMetrics.DEFAULT_MIN_REFRESH_DELAY; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.apache.accumulo.core.fate.FateExecutor; +import org.apache.accumulo.core.metrics.MetricsProducer; +import org.apache.accumulo.core.util.threads.ThreadPools; +import org.apache.accumulo.manager.tableOps.FateEnv; +import org.apache.accumulo.server.ServerContext; + +import io.micrometer.core.instrument.MeterRegistry; + +public class FateExecutorMetricsProducer implements MetricsProducer { + private final Set> fateExecutors; + private final ServerContext context; + private final long refreshDelay; + private MeterRegistry registry; + + public FateExecutorMetricsProducer(ServerContext context, + Set> fateExecutors, long minimumRefreshDelay) { + this.context = context; + this.fateExecutors = fateExecutors; + this.refreshDelay = Math.max(DEFAULT_MIN_REFRESH_DELAY, minimumRefreshDelay); + } + + protected void update() { + // there may have been new fate executors added, so these need to be registered. + // fate executors removed will have their metrics removed from the registry before they are + // removed from the set. + if (registry != null) { + synchronized (fateExecutors) { + fateExecutors.forEach(fe -> { + var feMetrics = fe.getFateExecutorMetrics(); + if (!feMetrics.isRegistered()) { + feMetrics.registerMetrics(registry); + } + }); + } + } + } + + @Override + public void registerMetrics(final MeterRegistry registry) { + this.registry = registry; + synchronized (fateExecutors) { + fateExecutors.forEach(fe -> fe.getFateExecutorMetrics().registerMetrics(registry)); + } + + var future = context.getScheduledExecutor().scheduleAtFixedRate(this::update, refreshDelay, + refreshDelay, TimeUnit.MILLISECONDS); + ThreadPools.watchCriticalScheduledTask(future); + } +} diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateMetrics.java b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateMetrics.java index bf69885b9a1..16af60b4723 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateMetrics.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/FateMetrics.java @@ -25,18 +25,15 @@ import java.util.EnumMap; import java.util.Map.Entry; import java.util.Objects; -import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import org.apache.accumulo.core.fate.FateExecutor; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus; import org.apache.accumulo.core.metrics.MetricsProducer; import org.apache.accumulo.core.util.threads.ThreadPools; -import org.apache.accumulo.manager.tableOps.FateEnv; import org.apache.accumulo.server.ServerContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,25 +48,21 @@ public abstract class FateMetrics implements Metrics private static final Logger log = LoggerFactory.getLogger(FateMetrics.class); // limit calls to update fate counters to guard against hammering zookeeper. - private static final long DEFAULT_MIN_REFRESH_DELAY = TimeUnit.SECONDS.toMillis(5); + static final long DEFAULT_MIN_REFRESH_DELAY = TimeUnit.SECONDS.toMillis(5); private static final String OP_TYPE_TAG = "op.type"; protected final ServerContext context; protected final ReadOnlyFateStore> readOnlyFateStore; protected final long refreshDelay; - private final Set> fateExecutors; - private MeterRegistry registry; protected final AtomicLong totalCurrentOpsCount = new AtomicLong(0); private final EnumMap txStatusCounters = new EnumMap<>(TStatus.class); - public FateMetrics(final ServerContext context, final long minimumRefreshDelay, - Set> fateExecutors) { + public FateMetrics(final ServerContext context, final long minimumRefreshDelay) { this.context = context; this.refreshDelay = Math.max(DEFAULT_MIN_REFRESH_DELAY, minimumRefreshDelay); this.readOnlyFateStore = Objects.requireNonNull(buildReadOnlyStore(context)); - this.fateExecutors = fateExecutors; for (TStatus status : TStatus.values()) { txStatusCounters.put(status, new AtomicLong(0)); @@ -98,25 +91,10 @@ protected void update(T metricValues) { metricValues.getOpTypeCounters().forEach((name, count) -> Metrics .gauge(FATE_TYPE_IN_PROGRESS.getName(), Tags.of(OP_TYPE_TAG, name), count)); - - // there may have been new fate executors added, so these need to be registered. - // fate executors removed will have their metrics removed from the registry before they are - // removed from the set. - if (registry != null) { - synchronized (fateExecutors) { - fateExecutors.forEach(fe -> { - var feMetrics = fe.getFateExecutorMetrics(); - if (!feMetrics.isRegistered()) { - feMetrics.registerMetrics(registry); - } - }); - } - } } @Override public void registerMetrics(final MeterRegistry registry) { - this.registry = registry; String type = readOnlyFateStore.type().name().toLowerCase(); Gauge.builder(FATE_OPS.getName(), totalCurrentOpsCount, AtomicLong::get) @@ -126,10 +104,6 @@ public void registerMetrics(final MeterRegistry registry) { .builder(FATE_TX.getName(), counter, AtomicLong::get).description(FATE_TX.getDescription()) .tags("state", status.name().toLowerCase(), "instanceType", type).register(registry)); - synchronized (fateExecutors) { - fateExecutors.forEach(fe -> fe.getFateExecutorMetrics().registerMetrics(registry)); - } - // get fate status is read only operation - no reason to be nice on shutdown. ScheduledExecutorService scheduler = ThreadPools.getServerThreadPools() .createScheduledExecutorService(1, type + "FateMetricsPoller"); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/meta/MetaFateMetrics.java b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/meta/MetaFateMetrics.java index 7e19d70e847..9d87f9a9cc2 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/meta/MetaFateMetrics.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/meta/MetaFateMetrics.java @@ -21,15 +21,12 @@ import static org.apache.accumulo.core.metrics.Metric.FATE_ERRORS; import static org.apache.accumulo.core.metrics.Metric.FATE_OPS_ACTIVITY; -import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import org.apache.accumulo.core.Constants; -import org.apache.accumulo.core.fate.FateExecutor; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.zookeeper.MetaFateStore; import org.apache.accumulo.manager.metrics.fate.FateMetrics; -import org.apache.accumulo.manager.tableOps.FateEnv; import org.apache.accumulo.server.ServerContext; import org.apache.zookeeper.KeeperException; @@ -41,9 +38,8 @@ public class MetaFateMetrics extends FateMetrics { private final AtomicLong totalOpsGauge = new AtomicLong(0); private final AtomicLong fateErrorsGauge = new AtomicLong(0); - public MetaFateMetrics(ServerContext context, long minimumRefreshDelay, - Set> fateExecutors) { - super(context, minimumRefreshDelay, fateExecutors); + public MetaFateMetrics(ServerContext context, long minimumRefreshDelay) { + super(context, minimumRefreshDelay); } @Override diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/user/UserFateMetrics.java b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/user/UserFateMetrics.java index 7fab73944d8..4f1df05762a 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/user/UserFateMetrics.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/metrics/fate/user/UserFateMetrics.java @@ -18,21 +18,16 @@ */ package org.apache.accumulo.manager.metrics.fate.user; -import java.util.Set; - -import org.apache.accumulo.core.fate.FateExecutor; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.user.UserFateStore; import org.apache.accumulo.core.metadata.SystemTables; import org.apache.accumulo.manager.metrics.fate.FateMetrics; -import org.apache.accumulo.manager.tableOps.FateEnv; import org.apache.accumulo.server.ServerContext; public class UserFateMetrics extends FateMetrics { - public UserFateMetrics(ServerContext context, long minimumRefreshDelay, - Set> fateExecutors) { - super(context, minimumRefreshDelay, fateExecutors); + public UserFateMetrics(ServerContext context, long minimumRefreshDelay) { + super(context, minimumRefreshDelay); } @Override diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/split/Splitter.java b/server/manager/src/main/java/org/apache/accumulo/manager/split/Splitter.java index 1f21fde170e..93d4c1cf03e 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/split/Splitter.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/split/Splitter.java @@ -89,7 +89,7 @@ public void run() { private void seedSplits(FateInstanceType instanceType, Map splits) { if (!splits.isEmpty()) { - try (var seeder = manager.fate(instanceType).beginSeeding()) { + try (var seeder = manager.fateClient(instanceType).beginSeeding()) { for (KeyExtent extent : splits.values()) { @SuppressWarnings("unused") var unused = seeder.attemptToSeedTransaction(Fate.FateOperation.SYSTEM_SPLIT, diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/FateEnv.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/FateEnv.java index 4631a28912e..e8e0085e3db 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/FateEnv.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/FateEnv.java @@ -55,7 +55,7 @@ public interface FateEnv { ExecutorService getTabletRefreshThreadPool(); - FileRangeCache getSplitFileCache(); + FileRangeCache getFileRangeCache(); ExecutorService getRenamePool(); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/PreSplit.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/PreSplit.java index 9b1eaf6d682..ed6879eaffd 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/PreSplit.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/PreSplit.java @@ -107,7 +107,7 @@ public long isReady(FateId fateId, FateEnv env) throws Exception { // now that the operation id set, generate an event to unload the tablet or recover the // logs env.getEventPublisher().event(splitInfo.getOriginal(), - "Set operation id %s on tablet for split", fateId); + "Set operation id %s on tablet %s for split", fateId, splitInfo.getOriginal()); // the operation id was set, but a location is also set wait for it be unset return 1000; } diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java index 4c9b1f11c47..ec34f80700c 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java @@ -111,7 +111,7 @@ public Repo call(FateId fateId, FateEnv env) throws Exception { var newTablets = splitInfo.getTablets(); var newTabletsFiles = getNewTabletFiles(fateId, newTablets, tabletMetadata, - file -> env.getSplitFileCache().getCachedFileInfo(splitInfo.getOriginal().tableId(), file)); + file -> env.getFileRangeCache().getCachedFileInfo(splitInfo.getOriginal().tableId(), file)); addNewTablets(fateId, env, tabletMetadata, opid, newTablets, newTabletsFiles); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java index 2464c9476bf..a230dc7149a 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java @@ -253,6 +253,8 @@ public void upgradeZookeeper(ServerContext context) { addDefaultResourceGroupConfigNode(context); LOG.info("Moving table properties from system to namespaces"); moveTableProperties(context); + LOG.info("Add assistant manager node"); + addAssistantManager(context); } @Override @@ -297,6 +299,15 @@ public void upgradeMetadata(ServerContext context) { removeBulkFileColumnsFromTable(context, SystemTables.METADATA.tableName()); } + private static void addAssistantManager(ServerContext context) { + try { + context.getZooSession().asReaderWriter().putPersistentData(Constants.ZMANAGER_ASSISTANT_LOCK, + new byte[0], ZooUtil.NodeExistsPolicy.SKIP); + } catch (KeeperException | InterruptedException e) { + throw new IllegalStateException(e); + } + } + private static void addCompactionsNode(ServerContext context) { try { context.getZooSession().asReaderWriter().putPersistentData(Constants.ZCOMPACTIONS, diff --git a/server/manager/src/test/java/org/apache/accumulo/manager/compaction/CompactionCoordinatorTest.java b/server/manager/src/test/java/org/apache/accumulo/manager/compaction/CompactionCoordinatorTest.java index b121faf2b39..487d32c74bf 100644 --- a/server/manager/src/test/java/org/apache/accumulo/manager/compaction/CompactionCoordinatorTest.java +++ b/server/manager/src/test/java/org/apache/accumulo/manager/compaction/CompactionCoordinatorTest.java @@ -39,7 +39,6 @@ import java.util.UUID; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.admin.CompactionConfig; @@ -55,7 +54,6 @@ import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.dataImpl.thrift.TKeyExtent; -import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.iteratorsImpl.system.SystemIteratorUtil; @@ -79,7 +77,6 @@ import org.apache.accumulo.manager.compaction.coordinator.CompactionCoordinator; import org.apache.accumulo.manager.compaction.queue.CompactionJobPriorityQueue; import org.apache.accumulo.manager.compaction.queue.ResolvedCompactionJob; -import org.apache.accumulo.manager.tableOps.FateEnv; import org.apache.accumulo.server.ServerContext; import org.apache.accumulo.server.conf.TableConfiguration; import org.apache.accumulo.server.security.AuditedSecurityOperation; @@ -94,10 +91,6 @@ public class CompactionCoordinatorTest { - // Need a non-null fateInstances reference for CompactionCoordinator.compactionCompleted - private static final AtomicReference>> fateInstances = - new AtomicReference<>(Map.of()); - private static final ResourceGroupId GROUP_ID = ResourceGroupId.of("R2DQ"); private final HostAndPort tserverAddr = HostAndPort.fromParts("192.168.1.1", 9090); @@ -118,7 +111,7 @@ public class TestCoordinator extends CompactionCoordinator { private Set metadataCompactionIds = null; public TestCoordinator(Manager manager, List runningCompactions) { - super(manager, fateInstances); + super(manager, fit -> null); this.runningCompactions = runningCompactions; } diff --git a/server/manager/src/test/java/org/apache/accumulo/manager/tableOps/split/UpdateTabletsTest.java b/server/manager/src/test/java/org/apache/accumulo/manager/tableOps/split/UpdateTabletsTest.java index 81bf52ed6e0..73bc764c2e3 100644 --- a/server/manager/src/test/java/org/apache/accumulo/manager/tableOps/split/UpdateTabletsTest.java +++ b/server/manager/src/test/java/org/apache/accumulo/manager/tableOps/split/UpdateTabletsTest.java @@ -246,7 +246,7 @@ public void testManyColumns() throws Exception { .andReturn(newFileInfo("d", "f")); EasyMock.expect(fileRangeCache.getCachedFileInfo(tableId, file4)) .andReturn(newFileInfo("d", "j")); - EasyMock.expect(manager.getSplitFileCache()).andReturn(fileRangeCache).atLeastOnce(); + EasyMock.expect(manager.getFileRangeCache()).andReturn(fileRangeCache).atLeastOnce(); EasyMock.expect(manager.getSteadyTime()).andReturn(SteadyTime.from(100_000, TimeUnit.SECONDS)) .atLeastOnce(); diff --git a/test/src/main/java/org/apache/accumulo/test/ComprehensiveMultiManagerIT.java b/test/src/main/java/org/apache/accumulo/test/ComprehensiveMultiManagerIT.java new file mode 100644 index 00000000000..278a051ec8a --- /dev/null +++ b/test/src/main/java/org/apache/accumulo/test/ComprehensiveMultiManagerIT.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.test; + +import org.apache.accumulo.core.client.Accumulo; +import org.apache.accumulo.core.client.AccumuloClient; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.harness.MiniClusterConfigurationCallback; +import org.apache.accumulo.harness.SharedMiniClusterBase; +import org.apache.accumulo.manager.Manager; +import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; + +public class ComprehensiveMultiManagerIT extends ComprehensiveITBase { + + private static class ComprehensiveITConfiguration implements MiniClusterConfigurationCallback { + @Override + public void configureMiniCluster(MiniAccumuloConfigImpl cfg, + org.apache.hadoop.conf.Configuration coreSite) { + cfg.setProperty(Property.SSERV_CACHED_TABLET_METADATA_EXPIRATION, "5s"); + } + } + + @BeforeAll + public static void setup() throws Exception { + ComprehensiveITConfiguration c = new ComprehensiveITConfiguration(); + SharedMiniClusterBase.startMiniClusterWithConfig(c); + try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { + client.securityOperations().changeUserAuthorizations("root", AUTHORIZATIONS); + } + + // Start two more managers + getCluster().exec(Manager.class); + getCluster().exec(Manager.class); + } + + @AfterAll + public static void teardown() { + SharedMiniClusterBase.stopMiniCluster(); + } +} diff --git a/test/src/main/java/org/apache/accumulo/test/MultipleManagerIT.java b/test/src/main/java/org/apache/accumulo/test/MultipleManagerIT.java new file mode 100644 index 00000000000..e4bd311155d --- /dev/null +++ b/test/src/main/java/org/apache/accumulo/test/MultipleManagerIT.java @@ -0,0 +1,305 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.test; + +import static java.util.stream.Collectors.toSet; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.cli.ServerOpts; +import org.apache.accumulo.core.client.Accumulo; +import org.apache.accumulo.core.client.admin.CompactionConfig; +import org.apache.accumulo.core.clientImpl.ClientContext; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.fate.Fate; +import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; +import org.apache.accumulo.core.fate.FateStore; +import org.apache.accumulo.core.fate.user.UserFateStore; +import org.apache.accumulo.core.lock.ServiceLock; +import org.apache.accumulo.core.lock.ServiceLockPaths; +import org.apache.accumulo.core.lock.ServiceLockPaths.ServiceLockPath; +import org.apache.accumulo.core.metadata.SystemTables; +import org.apache.accumulo.core.util.UtilWaitThread; +import org.apache.accumulo.manager.Manager; +import org.apache.accumulo.manager.tableOps.FateEnv; +import org.apache.accumulo.manager.tableOps.TraceRepo; +import org.apache.accumulo.minicluster.ServerType; +import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.apache.accumulo.server.ServerContext; +import org.apache.accumulo.test.fate.FastFate; +import org.apache.accumulo.test.functional.ConfigurableMacBase; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.util.Sets; +import org.junit.jupiter.api.Test; +import org.slf4j.LoggerFactory; + +import com.google.common.net.HostAndPort; + +/** + * {@link ComprehensiveMultiManagerIT} runs multiple managers with lots of Accumulo APIs, however + * that does not actually verify that fate operations actually run on multiple managers. This test + * runs a smaller set of Accumulo API operations and does the following. + * + *
    + *
  • Starts new manager processes and verifies fate operations start running on them
  • + *
  • Kills assistant/non-primary manager processes and verifies the system recovers
  • + *
  • Kills primary manager process and verifies the system recovers
  • + *
  • Verifies that Accumulo API calls are not impacted by managers starting/stopping
  • + *
+ * + */ +public class MultipleManagerIT extends ConfigurableMacBase { + + // A manager that will quickly clean up fate reservations held by dead managers + public static class FastFateCleanupManager extends Manager { + protected FastFateCleanupManager(ServerOpts opts, String[] args) throws IOException { + super(opts, ServerContext::new, args); + } + + @Override + protected Fate createFateInstance(FateEnv env, FateStore store, + ServerContext context) { + LoggerFactory.getLogger(FastFateCleanupManager.class) + .info("Creating Fast fate cleanup manager for {}", store.type()); + return new FastFate<>(env, store, true, TraceRepo::toLogString, getConfiguration()); + } + + public static void main(String[] args) throws Exception { + try (FastFateCleanupManager manager = new FastFateCleanupManager(new ServerOpts(), args)) { + manager.runServer(); + } + } + } + + @Override + protected void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) { + // TODO add a way to start multiple managers to mini + cfg.getClusterServerConfiguration().setNumDefaultCompactors(8); + // Set this lower so that locks timeout faster + cfg.setProperty(Property.INSTANCE_ZK_TIMEOUT, "5s"); + cfg.setServerClass(ServerType.MANAGER, r -> FastFateCleanupManager.class); + super.configure(cfg, hadoopCoreSite); + } + + @Test + public void testFate() throws Exception { + + List managerWorkers = new ArrayList<>(); + var executor = Executors.newCachedThreadPool(); + + // Start a lot of background threads that should cause fate operations to run. + try (var client = Accumulo.newClient().from(getClientProperties()).build()) { + // Create a table in order to wait for the single manager to become the primary manager + client.tableOperations().create("waitTable"); + + // start more manager processes, should be assigned fate work + managerWorkers.add(exec(FastFateCleanupManager.class)); + managerWorkers.add(exec(FastFateCleanupManager.class)); + + AtomicBoolean stop = new AtomicBoolean(false); + + var splits = IntStream.range(1, 10).mapToObj(i -> String.format("%03d", i)).map(Text::new) + .collect(Collectors.toCollection(TreeSet::new)); + var tableOpFutures = new ArrayList>(); + for (int i = 0; i < 10; i++) { + var table = "t" + i; + + // FOLLOW_ON its hard to find everything related to a table id in the logs across processes, + // especially when the + // table id is like "b". Was trying to follow a single table across multiple manager workers + // processes. + var tableOpsFuture = executor.submit(() -> { + int loops = 0; + while (!stop.get() || loops == 0) { + client.tableOperations().create(table); + log.info("Created table {}", table); + if (stop.get() && loops > 0) { + break; + } + var expectedRows = new HashSet(); + try (var writer = client.createBatchWriter(table)) { + for (int r = 0; r < 10; r++) { + var row = String.format("%03d", r); + expectedRows.add(row); + Mutation m = new Mutation(row); + m.put("f", "q", "v"); + writer.addMutation(m); + } + } + log.info("Wrote data to table {}", table); + if (stop.get() && loops > 0) { + break; + } + client.tableOperations().addSplits(table, splits); + log.info("Split table {}", table); + if (stop.get() && loops > 0) { + break; + } + client.tableOperations().compact(table, new CompactionConfig().setWait(true)); + log.info("Compacted table {}", table); + if (stop.get() && loops > 0) { + break; + } + client.tableOperations().merge(table, null, null); + log.info("Merged table {}", table); + if (stop.get() && loops > 0) { + break; + } + try (var scanner = client.createScanner(table)) { + var rowsSeen = + scanner.stream().map(e -> e.getKey().getRowData().toString()).collect(toSet()); + assertEquals(expectedRows, rowsSeen); + log.info("verified table {}", table); + } + client.tableOperations().delete(table); + log.info("Deleted table {}", table); + loops++; + } + return loops; + }); + tableOpFutures.add(tableOpsFuture); + } + + var ctx = getServerContext(); + + var store = new UserFateStore(ctx, SystemTables.FATE.tableName(), null, null); + + // Wait until three different manager are seen running fate operations. + waitToSeeManagers(ctx, 3, store, false); + + // Start two new manager processes and wait until 5 managers are seen running fate operations + managerWorkers.add(exec(FastFateCleanupManager.class)); + managerWorkers.add(exec(FastFateCleanupManager.class)); + waitToSeeManagers(ctx, 5, store, false); + + // Kill two assistant manager processes. Any fate operations that were running should resume + // elsewhere. Should see three manager running operations after that. + managerWorkers.get(2).destroy(); + managerWorkers.get(3).destroy(); + log.debug("Killed 2 managers"); + waitToSeeManagers(ctx, 3, store, true); + + // Delete the lock of the primary manager which should cause it to halt. Then wait to see two + // assistant managers. + var primaryManager = ctx.getServerPaths().getManager(true); + ServiceLock.deleteLock(ctx.getZooSession().asReaderWriter(), primaryManager); + log.debug("Deleted lock of primary manager"); + waitToSeeManagers(ctx, 2, store, true); + + stop.set(true); + // Wait for the background operations to complete and ensure that none had errors. Managers + // stoppping/starting should not cause any problems for Accumulo API operations. + for (var tof : tableOpFutures) { + int loops = tof.get(); + log.debug("Background thread loops {}", loops); + // Check that each background thread made a least one loop over all its table operations. + assertTrue(loops > 0); + } + } + + executor.shutdown(); + + managerWorkers.forEach(Process::destroy); + } + + private static void waitToSeeManagers(ClientContext context, int expectedManagers, + UserFateStore store, boolean managersKilled) { + + // Track what reservations exist when entering, want to see new reservations created during this + // function call. + var existingReservationUUIDs = + store.getActiveReservations(Set.of(FatePartition.all(FateInstanceType.USER))).values() + .stream().map(FateStore.FateReservation::getReservationUUID).collect(toSet()); + log.debug("existingReservationUUIDs {}", existingReservationUUIDs); + + var assistants = + context.getServerPaths().getAssistantManagers(ServiceLockPaths.AddressSelector.all(), true); + // Wait for there to be the expected number of managers in zookeeper. After manager processes + // are kill these entries in zookeeper may persist for a bit. + while (assistants.size() != expectedManagers) { + UtilWaitThread.sleep(1); + assistants = context.getServerPaths() + .getAssistantManagers(ServiceLockPaths.AddressSelector.all(), true); + } + + var expectedServers = assistants.stream().map(ServiceLockPath::getServer) + .map(HostAndPort::fromString).collect(toSet()); + log.debug("managers seen in zookeeper :{}", expectedServers); + + Set reservationsSeen = new HashSet<>(); + Set extraSeen = new HashSet<>(); + Set expectedPrefixes = + Set.of('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); + // Track fate uuid prefixes seen. This is done because fate is partitioned across managers by + // uuid ranges. If all uuid prefixes are seen then it is an indication that fate ids are being + // processed. After new manager processes are started or stopped the partitions should be + // reassigned. + Set seenPrefixes = new HashSet<>(); + + while (reservationsSeen.size() < expectedManagers || !seenPrefixes.equals(expectedPrefixes)) { + var reservations = + store.getActiveReservations(Set.of(FatePartition.all(FateInstanceType.USER))); + reservations.forEach((fateId, reservation) -> { + var slp = ServiceLockPaths.parse(Optional.empty(), reservation.getLockID().path); + if (slp.getType().equals(Constants.ZMANAGER_ASSISTANT_LOCK)) { + var hostPort = HostAndPort.fromString(slp.getServer()); + if (expectedServers.contains(hostPort)) { + if (!existingReservationUUIDs.contains(reservation.getReservationUUID())) { + reservationsSeen.add(hostPort); + Character prefix = fateId.getTxUUIDStr().charAt(0); + if (seenPrefixes.add(prefix)) { + log.debug("Saw fate uuid prefix {} in id {} still waiting for {}", prefix, fateId, + Sets.difference(expectedPrefixes, seenPrefixes)); + } + } + } else if (!managersKilled) { + fail("Saw unexpected extra manager " + slp); + } else { + extraSeen.add(hostPort); + } + } + }); + UtilWaitThread.sleep(1); + } + + log.debug("managers seen in fate reservations :{}", reservationsSeen); + if (managersKilled) { + log.debug("killed managers seen in fate reservations : {}", extraSeen); + } + assertEquals(expectedManagers, reservationsSeen.size()); + } +} diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateExecutionOrderITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/FateExecutionOrderITBase.java index ee3427fc2c2..4bbf06e0a1a 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FateExecutionOrderITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FateExecutionOrderITBase.java @@ -54,6 +54,7 @@ import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.Fate.TxInfo; import org.apache.accumulo.core.fate.FateId; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.Repo; import org.apache.accumulo.harness.SharedMiniClusterBase; @@ -194,9 +195,11 @@ private void waitFor(FateStore store, FateId txid) throws Exception } protected Fate initializeFate(AccumuloClient client, FateStore store) { - return new Fate<>(new FeoTestEnv(client), store, false, r -> r + "", + var fate = new Fate<>(new FeoTestEnv(client), store, false, r -> r + "", FateTestUtil.updateFateConfig(new ConfigurationCopy(), 1, "AllFateOps"), new ScheduledThreadPoolExecutor(2)); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); + return fate; } private static Entry toIdStep(Entry e) { diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/FateITBase.java index 278f65d33a2..1411e258ccb 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FateITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FateITBase.java @@ -24,6 +24,7 @@ import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.IN_PROGRESS; import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.NEW; import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUBMITTED; +import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.SUCCESSFUL; import static org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus.UNKNOWN; import static org.apache.accumulo.test.fate.FateTestUtil.TEST_FATE_OP; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -47,10 +48,11 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.accumulo.core.conf.ConfigurationCopy; -import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.fate.AbstractFateStore; import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; +import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus; @@ -559,9 +561,11 @@ private void submitDeferred(Fate fate, ServerContext sctx, Set } protected Fate initializeFate(FateStore store) { - return new Fate<>(new TestEnv(), store, false, r -> r + "", + var fate = new Fate<>(new TestEnv(), store, false, r -> r + "", FateTestUtil.updateFateConfig(new ConfigurationCopy(), 1, "AllFateOps"), new ScheduledThreadPoolExecutor(2)); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); + return fate; } protected abstract TStatus getTxStatus(ServerContext sctx, FateId fateId); @@ -574,9 +578,6 @@ public void testShutdownDoesNotFailTx() throws Exception { protected void testShutdownDoesNotFailTx(FateStore store, ServerContext sctx) throws Exception { - ConfigurationCopy config = new ConfigurationCopy(); - config.set(Property.GENERAL_THREADPOOL_SIZE, "2"); - Fate fate = initializeFate(store); // Wait for the transaction runner to be scheduled. @@ -633,6 +634,128 @@ protected void testShutdownDoesNotFailTx(FateStore store, ServerContext assertNull(interruptedException.get()); } + public static class DoNothingRepo implements Repo { + private static final long serialVersionUID = 1L; + + @Override + public Repo call(FateId fateId, TestEnv environment) throws Exception { + return null; + } + + @Override + public void undo(FateId fateId, TestEnv environment) throws Exception { + + } + + @Override + public String getReturn() { + return ""; + } + + @Override + public long isReady(FateId fateId, TestEnv environment) throws Exception { + return 0; + } + + @Override + public String getName() { + return "none"; + } + } + + @Test + @Timeout(60) + public void testPartitions() throws Exception { + executeTest(this::testPartitions); + } + + protected void testPartitions(FateStore store, ServerContext sctx) { + // This test ensures that fate only processes fateids that fall within its assigned partitions + // of fateids. + Fate fate = initializeFate(store); + fate.setPartitions(Set.of()); + + Set fateIds = new HashSet<>(); + + for (int i = 0; i < 100; i++) { + var txid = fate.startTransaction(); + fateIds.add(txid); + + fate.seedTransaction(TEST_FATE_OP, txid, new DoNothingRepo(), false, "no goal"); + } + + for (var fateId : fateIds) { + assertEquals(SUBMITTED, getTxStatus(sctx, fateId)); + } + + // start processing all uuids that start with 1 or 5, but no other ids + fate.setPartitions(Set.of(newPartition(store.type(), "1"), newPartition(store.type(), "5"))); + + Wait.waitFor(() -> fateIds.stream().filter( + fateId -> fateId.getTxUUIDStr().startsWith("1") || fateId.getTxUUIDStr().startsWith("5")) + .map(fateId -> getTxStatus(sctx, fateId)).allMatch(status -> status == SUCCESSFUL)); + + for (var fateId : fateIds) { + var uuid = fateId.getTxUUIDStr(); + if (uuid.startsWith("1") || uuid.startsWith("5")) { + assertEquals(SUCCESSFUL, getTxStatus(sctx, fateId)); + } else { + assertEquals(SUBMITTED, getTxStatus(sctx, fateId)); + } + } + + // start processing uuids that start with e + fate.setPartitions(Set.of(newPartition(store.type(), "e"))); + Wait.waitFor(() -> fateIds.stream().filter(fateId -> fateId.getTxUUIDStr().startsWith("e")) + .map(fateId -> getTxStatus(sctx, fateId)).allMatch(status -> status == SUCCESSFUL)); + + for (var fateId : fateIds) { + var uuid = fateId.getTxUUIDStr(); + if (uuid.startsWith("1") || uuid.startsWith("5") || uuid.startsWith("e")) { + assertEquals(SUCCESSFUL, getTxStatus(sctx, fateId)); + } else { + assertEquals(SUBMITTED, getTxStatus(sctx, fateId)); + } + } + + // add new ids to ensure that uuid prefixes 1 and 5 are no longer processed + Set fateIds2 = new HashSet<>(); + + for (int i = 0; i < 100; i++) { + var txid = fate.startTransaction(); + fateIds2.add(txid); + fate.seedTransaction(TEST_FATE_OP, txid, new DoNothingRepo(), false, "no goal"); + } + Wait.waitFor(() -> fateIds2.stream().filter(fateId -> fateId.getTxUUIDStr().startsWith("e")) + .map(fateId -> getTxStatus(sctx, fateId)).allMatch(status -> status == SUCCESSFUL)); + for (var fateId : fateIds2) { + var uuid = fateId.getTxUUIDStr(); + if (uuid.startsWith("e")) { + assertEquals(SUCCESSFUL, getTxStatus(sctx, fateId)); + } else { + assertEquals(SUBMITTED, getTxStatus(sctx, fateId)); + } + } + + // nothing should have changed with the first set of ids + for (var fateId : fateIds) { + var uuid = fateId.getTxUUIDStr(); + if (uuid.startsWith("1") || uuid.startsWith("5") || uuid.startsWith("e")) { + assertEquals(SUCCESSFUL, getTxStatus(sctx, fateId)); + } else { + assertEquals(SUBMITTED, getTxStatus(sctx, fateId)); + } + } + } + + private FatePartition newPartition(FateInstanceType type, String firstNibble) { + // these suffixes have all uuid chars except for the first nibble/4-bits + String zeroSuffix = "0000000-0000-0000-0000-000000000000"; + String ffSuffix = "fffffff-ffff-ffff-ffff-ffffffffffff"; + return new FatePartition(FateId.from(type, firstNibble + zeroSuffix), + FateId.from(type, firstNibble + ffSuffix)); + } + private static void inCall() throws InterruptedException { // signal that call started callStarted.countDown(); diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateOpsCommandsITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/FateOpsCommandsITBase.java index e0ff93e4a4f..280efe6312b 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FateOpsCommandsITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FateOpsCommandsITBase.java @@ -59,6 +59,7 @@ import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.user.UserFateStore; @@ -935,7 +936,10 @@ protected FastFate initFateWithDeadResCleaner(FateStore(env, store, true, Object::toString, DefaultConfiguration.getInstance()); + var fate = + new FastFate<>(env, store, true, Object::toString, DefaultConfiguration.getInstance()); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); + return fate; } protected Fate initFateNoDeadResCleaner(FateStore store) { diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FatePoolsWatcherITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/FatePoolsWatcherITBase.java index ae24acbfa02..c09a1ee737f 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FatePoolsWatcherITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FatePoolsWatcherITBase.java @@ -32,6 +32,7 @@ import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.Repo; import org.apache.accumulo.harness.SharedMiniClusterBase; @@ -92,6 +93,7 @@ protected void testIncrease1(FateStore store, ServerContext s final ConfigurationCopy config = initConfigIncTest1(); final var env = new PoolResizeTestEnv(); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); boolean isUserStore = store.type() == FateInstanceType.USER; final Set set1 = isUserStore ? USER_FATE_OPS_SET1 : META_FATE_OPS_SET1; final Set set2 = isUserStore ? USER_FATE_OPS_SET2 : META_FATE_OPS_SET2; @@ -224,6 +226,7 @@ protected void testIncrease2(FateStore store, ServerContext s FateTestUtil.updateFateConfig(new ConfigurationCopy(), 2, fateExecName); final var env = new PoolResizeTestEnv(); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); final int numWorkers = 2; final int newNumWorkers = 3; final Set allFateOps = @@ -305,6 +308,7 @@ protected void testDecrease(FateStore store, ServerContext sc final ConfigurationCopy config = initConfigDecTest(); final var env = new PoolResizeTestEnv(); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); boolean isUserStore = store.type() == FateInstanceType.USER; final Set set1 = isUserStore ? USER_FATE_OPS_SET1 : META_FATE_OPS_SET1; final Set set2 = isUserStore ? USER_FATE_OPS_SET2 : META_FATE_OPS_SET2; @@ -435,6 +439,7 @@ protected void testIdleCountHistory(FateStore store, ServerCo final var env = new PoolResizeTestEnv(); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); try { // We have two worker threads. Submit 3 transactions that won't complete yet so we can check // for a warning @@ -548,6 +553,7 @@ protected void testFatePoolsPartitioning(FateStore store, Ser final var env = new PoolResizeTestEnv(); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); try { // seeding pool1/FateExecutor1 @@ -650,6 +656,7 @@ protected void testFateExecutorRename(FateStore store, Server final var config = FateTestUtil.updateFateConfig(new ConfigurationCopy(), poolSize, "AllFateOps"); final Fate fate = new FastFate<>(env, store, false, r -> r + "", config); + fate.setPartitions(Set.of(FatePartition.all(store.type()))); try { // start a single transaction diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateStoreITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/FateStoreITBase.java index 2198b737675..36e0c0f2474 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FateStoreITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FateStoreITBase.java @@ -55,6 +55,7 @@ import org.apache.accumulo.core.fate.FateInstanceType; import org.apache.accumulo.core.fate.FateKey; import org.apache.accumulo.core.fate.FateKey.FateKeyType; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.FateStore.FateTxStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore.FateIdStatus; @@ -199,8 +200,8 @@ protected void testDeferredOverflow(FateStore store, ServerContext sctx try { // Run and verify all 10 transactions still exist and were not // run because of the deferral time of all the transactions - future = executor.submit(() -> store.runnable(keepRunning, - fateIdStatus -> transactions.remove(fateIdStatus.getFateId()))); + future = executor.submit(() -> store.runnable(Set.of(FatePartition.all(store.type())), + keepRunning::get, fateIdStatus -> transactions.remove(fateIdStatus.getFateId()))); Thread.sleep(2000); assertEquals(10, transactions.size()); // Setting this flag to false should terminate the task if sleeping @@ -225,8 +226,8 @@ protected void testDeferredOverflow(FateStore store, ServerContext sctx // Run and verify all 11 transactions were processed // and removed from the store keepRunning.set(true); - future = executor.submit(() -> store.runnable(keepRunning, - fateIdStatus -> transactions.remove(fateIdStatus.getFateId()))); + future = executor.submit(() -> store.runnable(Set.of(FatePartition.all(store.type())), + keepRunning::get, fateIdStatus -> transactions.remove(fateIdStatus.getFateId()))); Wait.waitFor(transactions::isEmpty); // Setting this flag to false should terminate the task if sleeping keepRunning.set(false); @@ -769,5 +770,4 @@ public TestOperation2() { super("testOperation2"); } } - } diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FlakyFateManager.java b/test/src/main/java/org/apache/accumulo/test/fate/FlakyFateManager.java index d8ea9578346..df5be7784cf 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FlakyFateManager.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FlakyFateManager.java @@ -35,10 +35,11 @@ protected FlakyFateManager(ServerOpts opts, String[] args) throws IOException { } @Override - protected Fate initializeFateInstance(ServerContext context, FateStore store) { + protected Fate createFateInstance(FateEnv env, FateStore store, + ServerContext context) { LoggerFactory.getLogger(FlakyFateManager.class).info("Creating Flaky Fate for {}", store.type()); - return new FlakyFate<>(this, store, TraceRepo::toLogString, getConfiguration()); + return new FlakyFate<>(env, store, TraceRepo::toLogString, getConfiguration()); } public static void main(String[] args) throws Exception { diff --git a/test/src/main/java/org/apache/accumulo/test/fate/MultipleStoresITBase.java b/test/src/main/java/org/apache/accumulo/test/fate/MultipleStoresITBase.java index d2c79855f4c..5a5a7734508 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/MultipleStoresITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/MultipleStoresITBase.java @@ -43,6 +43,7 @@ import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; +import org.apache.accumulo.core.fate.FatePartition; import org.apache.accumulo.core.fate.FateStore; import org.apache.accumulo.core.fate.ReadOnlyFateStore; import org.apache.accumulo.core.fate.Repo; @@ -103,9 +104,9 @@ private void testReserveUnreserve(TestStoreFactory testStoreFac assertTrue(store1.tryReserve(fakeFateId).isEmpty()); assertTrue(store2.tryReserve(fakeFateId).isEmpty()); // Both stores should return the same reserved transactions - activeReservations = store1.getActiveReservations(); + activeReservations = store1.getActiveReservations(Set.of(FatePartition.all(store1.type()))); assertEquals(allIds, activeReservations.keySet()); - activeReservations = store2.getActiveReservations(); + activeReservations = store2.getActiveReservations(Set.of(FatePartition.all(store2.type()))); assertEquals(allIds, activeReservations.keySet()); // Test setting/getting the TStatus and unreserving the transactions @@ -120,8 +121,8 @@ private void testReserveUnreserve(TestStoreFactory testStoreFac assertThrows(IllegalStateException.class, () -> reservation.setStatus(ReadOnlyFateStore.TStatus.NEW)); } - assertTrue(store1.getActiveReservations().isEmpty()); - assertTrue(store2.getActiveReservations().isEmpty()); + assertTrue(store1.getActiveReservations(Set.of(FatePartition.all(store1.type()))).isEmpty()); + assertTrue(store2.getActiveReservations(Set.of(FatePartition.all(store2.type()))).isEmpty()); } } @@ -254,8 +255,10 @@ private void testMultipleFateInstances(TestStoreFactory testSto Fate fate1 = new Fate<>(testEnv1, store1, true, Object::toString, DefaultConfiguration.getInstance(), new ScheduledThreadPoolExecutor(2)); + fate1.setPartitions(Set.of(FatePartition.all(store1.type()))); Fate fate2 = new Fate<>(testEnv2, store2, false, Object::toString, DefaultConfiguration.getInstance(), new ScheduledThreadPoolExecutor(2)); + fate2.setPartitions(Set.of(FatePartition.all(store2.type()))); try { for (int i = 0; i < numFateIds; i++) { @@ -320,8 +323,10 @@ private void testDeadReservationsCleanup(TestStoreFactory testStor try { fate1 = new FastFate<>(testEnv1, store1, true, Object::toString, config); + fate1.setPartitions(Set.of(FatePartition.all(store1.type()))); // Ensure nothing is reserved yet - assertTrue(store1.getActiveReservations().isEmpty()); + assertTrue( + store1.getActiveReservations(Set.of(FatePartition.all(store1.type()))).isEmpty()); // Create transactions for (int i = 0; i < numFateIds; i++) { @@ -337,7 +342,7 @@ private void testDeadReservationsCleanup(TestStoreFactory testStor // Each fate worker will be hung up working (IN_PROGRESS) on a single transaction // Verify store1 has the transactions reserved and that they were reserved with lock1 - reservations = store1.getActiveReservations(); + reservations = store1.getActiveReservations(Set.of(FatePartition.all(store1.type()))); assertEquals(allIds, reservations.keySet()); reservations.values().forEach(res -> assertEquals(lock1, res.getLockID())); @@ -345,7 +350,7 @@ private void testDeadReservationsCleanup(TestStoreFactory testStor // Verify store2 can see the reserved transactions even though they were reserved using // store1 - reservations = store2.getActiveReservations(); + reservations = store2.getActiveReservations(Set.of(FatePartition.all(store2.type()))); assertEquals(allIds, reservations.keySet()); reservations.values().forEach(res -> assertEquals(lock1, res.getLockID())); @@ -361,6 +366,7 @@ private void testDeadReservationsCleanup(TestStoreFactory testStor // fate1. fate2 = new Fate<>(testEnv2, store2, false, Object::toString, config, new ScheduledThreadPoolExecutor(2)); + fate2.setPartitions(Set.of(FatePartition.all(store2.type()))); // Wait for the "dead" reservations to be deleted and picked up again (reserved using // fate2/store2/lock2 now). @@ -370,7 +376,7 @@ private void testDeadReservationsCleanup(TestStoreFactory testStor // the workers for fate1 are hung up Wait.waitFor(() -> { Map store2Reservations = - store2.getActiveReservations(); + store2.getActiveReservations(Set.of(FatePartition.all(store2.type()))); boolean allReservedWithLock2 = store2Reservations.values().stream() .allMatch(entry -> entry.getLockID().equals(lock2)); return store2Reservations.keySet().equals(allIds) && allReservedWithLock2; diff --git a/test/src/main/java/org/apache/accumulo/test/fate/SlowFateSplitManager.java b/test/src/main/java/org/apache/accumulo/test/fate/SlowFateSplitManager.java index 1b68fec1c8e..9e69845b27f 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/SlowFateSplitManager.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/SlowFateSplitManager.java @@ -45,9 +45,10 @@ protected SlowFateSplitManager(ServerOpts opts, String[] args) throws IOExceptio } @Override - protected Fate initializeFateInstance(ServerContext context, FateStore store) { + protected Fate createFateInstance(FateEnv env, FateStore store, + ServerContext context) { log.info("Creating Slow Split Fate for {}", store.type()); - return new SlowFateSplit<>(this, store, TraceRepo::toLogString, getConfiguration()); + return new SlowFateSplit<>(env, store, TraceRepo::toLogString, getConfiguration()); } public static void main(String[] args) throws Exception {