Skip to content

Commit

Permalink
Merge branch 'main' into elasticity
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanielr committed Jan 22, 2024
2 parents bd7d82e + bed5e36 commit fd387ba
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 53 deletions.
2 changes: 1 addition & 1 deletion assemble/conf/accumulo-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if [[ -n $CLASSPATH ]]; then
else
CLASSPATH="${conf}"
fi
ZK_JARS=$(find "$ZOOKEEPER_HOME/lib/" -maxdepth 1 -name '*.jar' -not -name '*slf4j*' -not -name '*log4j*' | paste -sd:)
ZK_JARS=$(find "$ZOOKEEPER_HOME/lib/" -maxdepth 1 -name '*.jar' -not -name '*slf4j*' -not -name '*log4j*' | paste -sd: -)
# lib is set by calling script that sources this env file
#shellcheck disable=SC2154
CLASSPATH="${CLASSPATH}:${lib}/*:${HADOOP_CONF_DIR}:${ZOOKEEPER_HOME}/*:${ZK_JARS}:${HADOOP_HOME}/share/hadoop/client/*"
Expand Down
42 changes: 21 additions & 21 deletions assemble/src/main/resources/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -678,27 +678,27 @@ to the terms and conditions of the following licenses.

## org.slf4j:slf4j-api

Copyright (c) 2004-2017 QOS.ch
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2004-2023 QOS.ch
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Various dependencies under the CC0 license / public domain

Expand Down
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@
<version.auto-service>1.1.1</version.auto-service>
<version.bouncycastle>1.77</version.bouncycastle>
<version.curator>5.5.0</version.curator>
<version.errorprone>2.23.0</version.errorprone>
<version.errorprone>2.24.1</version.errorprone>
<version.hadoop>3.3.6</version.hadoop>
<version.opentelemetry>1.33.0</version.opentelemetry>
<version.slf4j>2.0.9</version.slf4j>
<version.opentelemetry>1.34.1</version.opentelemetry>
<version.powermock>2.0.9</version.powermock>
<version.slf4j>2.0.11</version.slf4j>
<version.thrift>0.17.0</version.thrift>
<version.zookeeper>3.9.1</version.zookeeper>
</properties>
Expand All @@ -159,14 +160,14 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-bom</artifactId>
<version>1.12.1</version>
<version>1.12.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -195,7 +196,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.22.0</version>
<version>2.22.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -296,7 +297,7 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand All @@ -306,7 +307,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;

import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -132,27 +133,28 @@ public TableState getTableState(TableId tableId) {
return tableStateCache.get(tableId);
}

public synchronized void transitionTableState(final TableId tableId, final TableState newState) {
public synchronized void transitionTableState(final TableId tableId, final TableState newState,
final EnumSet<TableState> expectedCurrStates) {
Preconditions.checkArgument(newState != TableState.UNKNOWN);
String statePath = zkRoot + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE;

try {
zoo.mutateOrCreate(statePath, newState.name().getBytes(UTF_8), oldData -> {
TableState oldState = TableState.UNKNOWN;
if (oldData != null) {
oldState = TableState.valueOf(new String(oldData, UTF_8));
zoo.mutateOrCreate(statePath, newState.name().getBytes(UTF_8), currData -> {
TableState currState = TableState.UNKNOWN;
if (currData != null) {
currState = TableState.valueOf(new String(currData, UTF_8));
}

// this check makes the transition operation idempotent
if (oldState == newState) {
if (currState == newState) {
return null; // already at desired state, so nothing to do
}

boolean transition = true;
// +--------+
// v |
// NEW -> (ONLINE|OFFLINE)+--- DELETING
switch (oldState) {
switch (currState) {
case NEW:
transition = (newState == TableState.OFFLINE || newState == TableState.ONLINE);
break;
Expand All @@ -166,10 +168,10 @@ public synchronized void transitionTableState(final TableId tableId, final Table
transition = false;
break;
}
if (!transition) {
throw new IllegalTableTransitionException(oldState, newState);
if (!transition || !expectedCurrStates.contains(currState)) {
throw new IllegalTableTransitionException(currState, newState);
}
log.debug("Transitioning state for table {} from {} to {}", tableId, oldState, newState);
log.debug("Transitioning state for table {} from {} to {}", tableId, currState, newState);
return newState.name().getBytes(UTF_8);
});
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ long getCandidateBatchSize() {
/**
* Checks if safemode is set - files will not be deleted.
*
* @return number of delete threads
* @return true if safe mode is set, false otherwise
*/
boolean inSafeMode() {
return getConfiguration().getBoolean(Property.GC_SAFEMODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Base64;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -70,6 +71,7 @@
import org.apache.accumulo.core.dataImpl.thrift.TRange;
import org.apache.accumulo.core.fate.FateInstanceType;
import org.apache.accumulo.core.fate.ReadOnlyFateStore.TStatus;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.core.manager.thrift.BulkImportState;
import org.apache.accumulo.core.manager.thrift.FateOperation;
import org.apache.accumulo.core.manager.thrift.FateService;
Expand Down Expand Up @@ -407,9 +409,12 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, Fate
}

goalMessage += "Online table " + tableId;
final EnumSet<TableState> expectedCurrStates =
EnumSet.of(TableState.ONLINE, TableState.OFFLINE);
manager.fate(type).seedTransaction(op.toString(), tid,
new TraceRepo<>(new ChangeTableState(namespaceId, tableId, tableOp)), autoCleanup,
goalMessage);
new TraceRepo<>(
new ChangeTableState(namespaceId, tableId, tableOp, expectedCurrStates)),
autoCleanup, goalMessage);
break;
}
case TABLE_OFFLINE: {
Expand All @@ -432,9 +437,12 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, Fate
}

goalMessage += "Offline table " + tableId;
final EnumSet<TableState> expectedCurrStates =
EnumSet.of(TableState.ONLINE, TableState.OFFLINE);
manager.fate(type).seedTransaction(op.toString(), tid,
new TraceRepo<>(new ChangeTableState(namespaceId, tableId, tableOp)), autoCleanup,
goalMessage);
new TraceRepo<>(
new ChangeTableState(namespaceId, tableId, tableOp, expectedCurrStates)),
autoCleanup, goalMessage);
break;
}
case TABLE_MERGE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.accumulo.manager.tableOps;

import java.util.EnumSet;

import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
Expand All @@ -32,11 +34,14 @@ public class ChangeTableState extends ManagerRepo {
private TableId tableId;
private NamespaceId namespaceId;
private TableOperation top;
private final EnumSet<TableState> expectedCurrStates;

public ChangeTableState(NamespaceId namespaceId, TableId tableId, TableOperation top) {
public ChangeTableState(NamespaceId namespaceId, TableId tableId, TableOperation top,
EnumSet<TableState> expectedCurrStates) {
this.tableId = tableId;
this.namespaceId = namespaceId;
this.top = top;
this.expectedCurrStates = expectedCurrStates;

if (top != TableOperation.ONLINE && top != TableOperation.OFFLINE) {
throw new IllegalArgumentException(top.toString());
Expand All @@ -58,7 +63,7 @@ public Repo<Manager> call(long tid, Manager env) {
ts = TableState.OFFLINE;
}

env.getTableManager().transitionTableState(tableId, ts);
env.getTableManager().transitionTableState(tableId, ts, expectedCurrStates);
Utils.unreserveNamespace(env, namespaceId, tid, false);
Utils.unreserveTable(env, tableId, tid, true);
LoggerFactory.getLogger(ChangeTableState.class).debug("Changed table state {} {}", tableId, ts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.accumulo.manager.tableOps.clone;

import java.util.EnumSet;

import org.apache.accumulo.core.fate.Repo;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
Expand Down Expand Up @@ -47,12 +49,14 @@ public Repo<Manager> call(long tid, Manager environment) {
// may never create files.. therefore there is no need to consume namenode space w/ directories
// that are not used... tablet will create directories as needed

final EnumSet<TableState> expectedCurrStates = EnumSet.of(TableState.NEW);
if (cloneInfo.keepOffline) {
environment.getTableManager().transitionTableState(cloneInfo.tableId, TableState.OFFLINE);
environment.getTableManager().transitionTableState(cloneInfo.tableId, TableState.OFFLINE,
expectedCurrStates);
} else {
// transition clone table state to state of original table
TableState ts = environment.getTableManager().getTableState(cloneInfo.srcTableId);
environment.getTableManager().transitionTableState(cloneInfo.tableId, ts);
environment.getTableManager().transitionTableState(cloneInfo.tableId, ts, expectedCurrStates);
}

Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, tid, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.accumulo.manager.tableOps.create;

import java.io.IOException;
import java.util.EnumSet;

import org.apache.accumulo.core.client.admin.InitialTableState;
import org.apache.accumulo.core.fate.Repo;
Expand Down Expand Up @@ -50,13 +51,14 @@ public long isReady(long tid, Manager environment) {

@Override
public Repo<Manager> call(long tid, Manager env) throws Exception {
final EnumSet<TableState> expectedCurrStates = EnumSet.of(TableState.NEW);

if (tableInfo.getInitialTableState() == InitialTableState.OFFLINE) {
env.getContext().getTableManager().transitionTableState(tableInfo.getTableId(),
TableState.OFFLINE);
TableState.OFFLINE, expectedCurrStates);
} else {
env.getContext().getTableManager().transitionTableState(tableInfo.getTableId(),
TableState.ONLINE);
TableState.ONLINE, expectedCurrStates);
}

Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), tid, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.accumulo.manager.tableOps.delete;

import java.util.EnumSet;

import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
Expand Down Expand Up @@ -47,7 +49,9 @@ public long isReady(long tid, Manager env) throws Exception {

@Override
public Repo<Manager> call(long tid, Manager env) {
env.getTableManager().transitionTableState(tableId, TableState.DELETING);
final EnumSet<TableState> expectedCurrStates =
EnumSet.of(TableState.ONLINE, TableState.OFFLINE);
env.getTableManager().transitionTableState(tableId, TableState.DELETING, expectedCurrStates);
env.getEventCoordinator().event(tableId, "deleting table %s ", tableId);
return new ReserveTablets(tableId, namespaceId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import static org.apache.accumulo.core.Constants.IMPORT_MAPPINGS_FILE;

import java.util.EnumSet;

import org.apache.accumulo.core.fate.Repo;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
Expand Down Expand Up @@ -52,8 +54,9 @@ public Repo<Manager> call(long tid, Manager env) throws Exception {
}
}

final EnumSet<TableState> expectedCurrStates = EnumSet.of(TableState.NEW);
final TableState newState = tableInfo.keepOffline ? TableState.OFFLINE : TableState.ONLINE;
env.getTableManager().transitionTableState(tableInfo.tableId, newState);
env.getTableManager().transitionTableState(tableInfo.tableId, newState, expectedCurrStates);

Utils.unreserveNamespace(env, tableInfo.namespaceId, tid, false);
Utils.unreserveTable(env, tableInfo.tableId, tid, true);
Expand Down

0 comments on commit fd387ba

Please sign in to comment.