This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluo.git
The following commit(s) were added to refs/heads/main by this push:
new e5dc57ff Fix build for newer Java
e5dc57ff is described below
commit e5dc57ff67c8dd3fda28b278f8bb0ab4587fcfd7
Author: Christopher Tubbs <[email protected]>
AuthorDate: Tue Mar 25 20:02:05 2025 -0400
Fix build for newer Java
---
.../org/apache/fluo/accumulo/values/LockValue.java | 2 +-
.../apache/fluo/accumulo/values/ReadLockValue.java | 2 +-
.../apache/fluo/accumulo/iterators/TestData.java | 2 +-
.../apache/fluo/accumulo/util/LongUtilTest.java | 8 +--
modules/api/pom.xml | 1 -
.../java/org/apache/fluo/api/client/Snapshot.java | 2 -
.../fluo/api/config/SimpleConfiguration.java | 20 ++++--
.../main/java/org/apache/fluo/api/data/Bytes.java | 5 +-
.../fluo/api/config/FluoConfigurationTest.java | 12 ++--
.../java/org/apache/fluo/api/data/ColumnTest.java | 1 -
modules/command/pom.xml | 4 ++
.../java/org/apache/fluo/command/CommandUtil.java | 8 +--
.../java/org/apache/fluo/command/FluoGetJars.java | 3 +-
.../java/org/apache/fluo/command/FluoInit.java | 4 +-
.../java/org/apache/fluo/command/FluoProgram.java | 4 +-
.../fluo/core/async/AsyncConditionalWriter.java | 4 +-
.../org/apache/fluo/core/async/CommitManager.java | 2 +-
.../org/apache/fluo/core/client/FluoAdminImpl.java | 12 ++--
.../apache/fluo/core/client/FluoClientImpl.java | 5 +-
.../fluo/core/client/LoaderExecutorAsyncImpl.java | 10 +--
.../org/apache/fluo/core/impl/Environment.java | 13 ++--
.../org/apache/fluo/core/impl/LockResolver.java | 9 ++-
.../org/apache/fluo/core/impl/SharedResources.java | 2 +-
.../org/apache/fluo/core/impl/SnapshotScanner.java | 2 +-
.../org/apache/fluo/core/impl/TransactionImpl.java | 29 ++++----
.../org/apache/fluo/core/impl/TransactorCache.java | 2 +-
.../org/apache/fluo/core/impl/TransactorID.java | 2 +-
.../java/org/apache/fluo/core/impl/TxInfo.java | 18 ++++-
.../org/apache/fluo/core/impl/TxInfoCache.java | 8 +--
.../org/apache/fluo/core/metrics/MetricsUtil.java | 9 +--
.../core/metrics/starters/CsvReporterStarter.java | 8 +--
.../apache/fluo/core/observer/v1/ObserversV1.java | 26 +++----
.../fluo/core/observer/v2/ObserverStoreV2.java | 10 +--
.../apache/fluo/core/observer/v2/ObserversV2.java | 6 +-
.../apache/fluo/core/oracle/FluoOracleImpl.java | 9 +--
.../org/apache/fluo/core/oracle/OracleClient.java | 3 +-
.../org/apache/fluo/core/oracle/OracleServer.java | 7 +-
.../org/apache/fluo/core/util/CuratorUtil.java | 2 +-
.../apache/fluo/core/util/DeprecationUtil.java} | 31 ++++----
.../main/java/org/apache/fluo/core/util/Limit.java | 12 ++--
.../java/org/apache/fluo/core/util/PortUtils.java | 8 +--
.../java/org/apache/fluo/core/util/ScanUtil.java | 7 +-
.../apache/fluo/core/worker/FluoWorkerImpl.java | 7 +-
.../core/worker/NotificationFinderFactory.java | 9 +--
.../fluo/core/worker/NotificationProcessor.java | 6 +-
.../core/worker/finder/hash/PartitionManager.java | 5 +-
.../fluo/core/worker/finder/hash/HashTest.java | 7 +-
modules/integration-tests/pom.xml | 4 ++
.../java/org/apache/fluo/integration/ITBase.java | 11 +--
.../apache/fluo/integration/TestTransaction.java | 2 +-
.../fluo/integration/accumulo/TimeskippingIT.java | 8 ++-
.../fluo/integration/client/FluoClientIT.java | 3 -
.../apache/fluo/integration/impl/CollisionIT.java | 10 +--
.../apache/fluo/integration/impl/FailureIT.java | 3 -
.../impl/GarbageCollectionIteratorIT.java | 18 +----
.../org/apache/fluo/integration/impl/MiniIT.java | 10 +--
.../fluo/integration/impl/ReadLockFailureIT.java | 15 +---
.../apache/fluo/integration/impl/ReadLockIT.java | 11 +--
.../apache/fluo/integration/impl/ScannerIT.java | 58 +++++++--------
.../fluo/integration/impl/StochasticBankIT.java | 32 ++++-----
.../org/apache/fluo/integration/log/LogIT.java | 1 -
.../fluo/mapreduce/FluoEntryInputFormat.java | 1 -
.../apache/fluo/mapreduce/FluoRowInputFormat.java | 1 -
.../fluo/mapreduce/it/FluoFileOutputFormatIT.java | 18 ++---
.../java/org/apache/fluo/mini/MiniFluoImpl.java | 11 +--
pom.xml | 83 ++++++++++++++--------
66 files changed, 335 insertions(+), 333 deletions(-)
diff --git
a/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/LockValue.java
b/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/LockValue.java
index 3b7c54b4..cac2fa91 100644
---
a/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/LockValue.java
+++
b/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/LockValue.java
@@ -27,7 +27,7 @@ import static
org.apache.fluo.accumulo.format.FluoFormatter.encNonAscii;
/**
*
*/
-public class LockValue {
+public final class LockValue {
private final Bytes prow;
private final Column pcol;
diff --git
a/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/ReadLockValue.java
b/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/ReadLockValue.java
index 73451ae1..9ef9139c 100644
---
a/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/ReadLockValue.java
+++
b/modules/accumulo/src/main/java/org/apache/fluo/accumulo/values/ReadLockValue.java
@@ -24,7 +24,7 @@ import org.apache.fluo.api.data.Column;
import static org.apache.fluo.accumulo.format.FluoFormatter.encNonAscii;
-public class ReadLockValue {
+public final class ReadLockValue {
private final Bytes prow;
private final Column pcol;
private final Long transactor;
diff --git
a/modules/accumulo/src/test/java/org/apache/fluo/accumulo/iterators/TestData.java
b/modules/accumulo/src/test/java/org/apache/fluo/accumulo/iterators/TestData.java
index b34c9333..3561f460 100644
---
a/modules/accumulo/src/test/java/org/apache/fluo/accumulo/iterators/TestData.java
+++
b/modules/accumulo/src/test/java/org/apache/fluo/accumulo/iterators/TestData.java
@@ -38,7 +38,7 @@ import org.apache.fluo.accumulo.values.WriteValue;
import org.apache.fluo.api.data.Bytes;
import org.apache.fluo.api.data.Column;
-public class TestData {
+public final class TestData {
TreeMap<Key, Value> data = new TreeMap<>();
Counter counter = new Counter();
diff --git
a/modules/accumulo/src/test/java/org/apache/fluo/accumulo/util/LongUtilTest.java
b/modules/accumulo/src/test/java/org/apache/fluo/accumulo/util/LongUtilTest.java
index dcc2f6ff..6001caf8 100644
---
a/modules/accumulo/src/test/java/org/apache/fluo/accumulo/util/LongUtilTest.java
+++
b/modules/accumulo/src/test/java/org/apache/fluo/accumulo/util/LongUtilTest.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -25,14 +25,14 @@ public class LongUtilTest {
@Test
public void testAll() {
- Long longVal = new Long("34886");
+ Long longVal = Long.parseLong("34886");
String radixStr = LongUtil.toMaxRadixString(longVal);
Assert.assertEquals("qx2", radixStr);
Assert.assertEquals(longVal, LongUtil.fromMaxRadixString(radixStr));
Assert.assertEquals(longVal,
LongUtil.fromMaxRadixByteArray(LongUtil.toMaxRadixByteArray(longVal)));
- longVal = new Long("63832");
+ longVal = Long.parseLong("63832");
Assert.assertEquals(longVal,
LongUtil.fromByteArray(LongUtil.toByteArray(longVal)));
}
}
diff --git a/modules/api/pom.xml b/modules/api/pom.xml
index e240668c..1b5a1463 100644
--- a/modules/api/pom.xml
+++ b/modules/api/pom.xml
@@ -91,7 +91,6 @@
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>apilyzer-maven-plugin</artifactId>
- <version>1.0.1</version>
<executions>
<execution>
<id>apilyzer</id>
diff --git a/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
b/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
index 824a14e2..625cf626 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
@@ -15,8 +15,6 @@
package org.apache.fluo.api.client;
-import java.util.Collection;
-
/**
* Allows users to read from a Fluo table at a certain point in time. Snapshot
extends
* {@link SnapshotBase} to include a {@link #close} method which must be
called when you are
diff --git
a/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java
b/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java
index 88aebb0b..9c7cc9d7 100644
---
a/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java
+++
b/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -177,7 +177,7 @@ public class SimpleConfiguration implements Serializable {
/**
* Loads configuration from InputStream. Later loads have lower priority.
- *
+ *
* @param in InputStream to load from
* @since 1.2.0
*/
@@ -193,7 +193,7 @@ public class SimpleConfiguration implements Serializable {
/**
* Loads configuration from File. Later loads have lower priority.
- *
+ *
* @param file File to load from
* @since 1.2.0
*/
@@ -262,6 +262,7 @@ public class SimpleConfiguration implements Serializable {
*/
public String[] getProperties(String key) {
// TODO fix cast class; use Properties?
+ @SuppressWarnings("unchecked")
ArrayList<String> values = (ArrayList<String>)
internalConfig.getProperty(key);
if (values == null) {
return new String[0];
@@ -283,7 +284,7 @@ public class SimpleConfiguration implements Serializable {
* @param fallback SimpleConfiguration to join together
* @return a new simple configuration that contains all of the current
properties from this plus
* the properties from fallback that are not present in this.
- *
+ *
* @since 1.2.0
*/
public SimpleConfiguration orElse(SimpleConfiguration fallback) {
@@ -374,7 +375,7 @@ public class SimpleConfiguration implements Serializable {
result.write(buffer, 0, length);
}
- return result.toString(UTF_8.name());
+ return result.toString(UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -397,4 +398,11 @@ public class SimpleConfiguration implements Serializable {
return new StringReader(propsData);
}
+
+ // CHECKSTYLE:OFF: NoFinalizer
+ @Override
+ public final void finalize() {
+ // prevent CT_CONSTRUCTOR_THROW spotbugs warning about finalizer attacks
+ }
+ // CHECKSTYLE:ON: NoFinalizer
}
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
b/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
index ad0d784c..757b4b4a 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
@@ -512,7 +512,6 @@ public final class Bytes implements Comparable<Bytes>,
Serializable {
return append((String) cs);
}
-
ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(cs));
int length = bb.remaining();
@@ -582,7 +581,9 @@ public final class Bytes implements Comparable<Bytes>,
Serializable {
*/
public BytesBuilder append(InputStream in, int length) throws IOException {
ensureCapacity(len + length);
- new DataInputStream(in).readFully(ba, len, length);
+ // create an anonymous subclass of DataInputStream to avoid unclosed
resource warnings
+ // we don't close it because we don't want to close the provided
InputStream it is wrapping
+ new DataInputStream(in) {}.readFully(ba, len, length);
len += length;
return this;
}
diff --git
a/modules/api/src/test/java/org/apache/fluo/api/config/FluoConfigurationTest.java
b/modules/api/src/test/java/org/apache/fluo/api/config/FluoConfigurationTest.java
index d8c1b107..8567022f 100644
---
a/modules/api/src/test/java/org/apache/fluo/api/config/FluoConfigurationTest.java
+++
b/modules/api/src/test/java/org/apache/fluo/api/config/FluoConfigurationTest.java
@@ -17,10 +17,10 @@ package org.apache.fluo.api.config;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -175,9 +175,9 @@ public class FluoConfigurationTest {
@Test
public void testLoadingDistPropsFile() {
- File connectionProps = new
File("../distribution/src/main/config/fluo-conn.properties");
+ var connectionProps =
Path.of("../distribution/src/main/config/fluo-conn.properties").toFile();
Assert.assertTrue(connectionProps.exists());
- File applicationProps = new
File("../distribution/src/main/config/fluo-app.properties");
+ var applicationProps =
Path.of("../distribution/src/main/config/fluo-app.properties").toFile();
Assert.assertTrue(applicationProps.exists());
FluoConfiguration config = new FluoConfiguration(connectionProps);
@@ -211,7 +211,7 @@ public class FluoConfigurationTest {
@Test
public void testLoadingOldTestPropsFile() {
- File propsFile = new File("src/test/resources/fluo.properties");
+ var propsFile = Path.of("src/test/resources/fluo.properties").toFile();
Assert.assertTrue(propsFile.exists());
FluoConfiguration config = new FluoConfiguration(propsFile);
@@ -233,7 +233,7 @@ public class FluoConfigurationTest {
@Test
public void testLoadingTestPropsFile() {
- File applicationProps = new File("src/test/resources/fluo-app.properties");
+ var applicationProps =
Path.of("src/test/resources/fluo-app.properties").toFile();
Assert.assertTrue(applicationProps.exists());
FluoConfiguration config = new FluoConfiguration(applicationProps);
@@ -251,7 +251,7 @@ public class FluoConfigurationTest {
Assert.assertEquals(30000, config.getZookeeperTimeout());
Assert.assertEquals(-1, config.getConnectionRetryTimeout());
- File connectionProps = new File("src/test/resources/fluo-conn.properties");
+ var connectionProps =
Path.of("src/test/resources/fluo-conn.properties").toFile();
Assert.assertTrue(applicationProps.exists());
config.load(connectionProps);
Assert.assertEquals("localhost/test-fluo", config.getInstanceZookeepers());
diff --git a/modules/api/src/test/java/org/apache/fluo/api/data/ColumnTest.java
b/modules/api/src/test/java/org/apache/fluo/api/data/ColumnTest.java
index d28b158f..caa57430 100644
--- a/modules/api/src/test/java/org/apache/fluo/api/data/ColumnTest.java
+++ b/modules/api/src/test/java/org/apache/fluo/api/data/ColumnTest.java
@@ -16,7 +16,6 @@
package org.apache.fluo.api.data;
import java.util.Arrays;
-import java.util.List;
import org.junit.Assert;
import org.junit.Test;
diff --git a/modules/command/pom.xml b/modules/command/pom.xml
index 2f2f355c..1c40ee77 100644
--- a/modules/command/pom.xml
+++ b/modules/command/pom.xml
@@ -42,6 +42,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
diff --git
a/modules/command/src/main/java/org/apache/fluo/command/CommandUtil.java
b/modules/command/src/main/java/org/apache/fluo/command/CommandUtil.java
index 762f17d6..6da7f2d7 100644
--- a/modules/command/src/main/java/org/apache/fluo/command/CommandUtil.java
+++ b/modules/command/src/main/java/org/apache/fluo/command/CommandUtil.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -15,7 +15,7 @@
package org.apache.fluo.command;
-import java.io.File;
+import java.nio.file.Path;
import com.google.common.base.Preconditions;
import org.apache.fluo.api.config.FluoConfiguration;
@@ -48,7 +48,7 @@ public class CommandUtil {
if (connPropsPath == null) {
return new FluoConfiguration();
} else {
- File connPropsFile = new File(connPropsPath);
+ var connPropsFile = Path.of(connPropsPath).toFile();
Preconditions.checkArgument(connPropsFile.exists(),
"System property 'fluo.conn.props' is set to file that doesn't
exist: " + connPropsPath);
return new FluoConfiguration(connPropsFile);
diff --git
a/modules/command/src/main/java/org/apache/fluo/command/FluoGetJars.java
b/modules/command/src/main/java/org/apache/fluo/command/FluoGetJars.java
index 4f55bb22..2d86b280 100644
--- a/modules/command/src/main/java/org/apache/fluo/command/FluoGetJars.java
+++ b/modules/command/src/main/java/org/apache/fluo/command/FluoGetJars.java
@@ -15,7 +15,6 @@
package org.apache.fluo.command;
-import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -57,7 +56,7 @@ public class FluoGetJars extends AppCommand {
if (config.getObserverJarsUrl().startsWith("hdfs://")) {
try (FileSystem fs = FileSystem.get(new URI(config.getDfsRoot()), new
Configuration())) {
- File downloadPathFile = new File(getDownloadPath());
+ var downloadPathFile =
java.nio.file.Path.of(getDownloadPath()).toFile();
if (downloadPathFile.exists()) {
FileUtils.deleteDirectory(downloadPathFile);
}
diff --git
a/modules/command/src/main/java/org/apache/fluo/command/FluoInit.java
b/modules/command/src/main/java/org/apache/fluo/command/FluoInit.java
index e1c9bb20..a1883869 100644
--- a/modules/command/src/main/java/org/apache/fluo/command/FluoInit.java
+++ b/modules/command/src/main/java/org/apache/fluo/command/FluoInit.java
@@ -16,9 +16,9 @@
package org.apache.fluo.command;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.nio.file.Path;
import java.util.Optional;
import com.beust.jcommander.Parameter;
@@ -98,7 +98,7 @@ public class FluoInit extends AppCommand {
@Override
public void execute() throws FluoCommandException {
- File applicationPropsFile = new File(getAppPropsPath());
+ var applicationPropsFile = Path.of(getAppPropsPath()).toFile();
Preconditions.checkArgument(applicationPropsFile.exists(),
getAppPropsPath() + " does not exist");
diff --git
a/modules/command/src/main/java/org/apache/fluo/command/FluoProgram.java
b/modules/command/src/main/java/org/apache/fluo/command/FluoProgram.java
index dfa9beda..0842b3e5 100644
--- a/modules/command/src/main/java/org/apache/fluo/command/FluoProgram.java
+++ b/modules/command/src/main/java/org/apache/fluo/command/FluoProgram.java
@@ -21,7 +21,7 @@ import java.util.Optional;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
-import com.google.common.collect.Iterables;
+import com.google.common.collect.MoreCollectors;
public class FluoProgram {
@@ -58,7 +58,7 @@ public class FluoProgram {
String programName = String.format("fluo %s", parsedCommandType);
parsedJCommand.setProgramName(programName);
FluoCommand parsedFluoCommand =
- (FluoCommand) Iterables.getOnlyElement(parsedJCommand.getObjects());
+ (FluoCommand)
parsedJCommand.getObjects().stream().collect(MoreCollectors.onlyElement());
if (parsedFluoCommand.isHelp()) {
parsedJCommand.usage();
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/async/AsyncConditionalWriter.java
b/modules/core/src/main/java/org/apache/fluo/core/async/AsyncConditionalWriter.java
index c5a2f827..ad9882d0 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/async/AsyncConditionalWriter.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/async/AsyncConditionalWriter.java
@@ -43,13 +43,13 @@ public class AsyncConditionalWriter {
this.cw = cw;
int numThreads =
env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_CW_THREADS,
FluoConfigurationImpl.ASYNC_CW_THREADS_DEFAULT);
- int permits =
env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_CW_LIMIT,
+ int numPermits =
env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_CW_LIMIT,
FluoConfigurationImpl.ASYNC_CW_LIMIT_DEFAULT);
this.es = FluoExecutors.newFixedThreadPool(numThreads, "asyncCw");
// the conditional writer currently has not memory limits... give it too
much and it blows out
// memory.. need to fix this in conditional writer
// for now this needs to be memory based
- this.semaphore = new Limit(permits);
+ this.semaphore = new Limit(numPermits);
}
public CompletableFuture<Iterator<Result>>
apply(Collection<ConditionalMutation> input) {
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
b/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
index ffa42926..de65d87c 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
* of the queue does not have to.
*/
-public class CommitManager {
+public final class CommitManager {
private Limit memoryLimit;
private AtomicInteger commitingTransactions;
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
index 92e149b2..85e6c8ae 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
@@ -17,11 +17,9 @@ package org.apache.fluo.core.client;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Paths;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
@@ -66,6 +64,8 @@ import
org.apache.zookeeper.KeeperException.NodeExistsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.util.Objects.requireNonNull;
+
/**
* Fluo Admin Implementation
*/
@@ -395,8 +395,7 @@ public class FluoAdminImpl implements FluoAdmin {
StringBuilder classpath = new StringBuilder();
for (String jarPath : jars.split(",")) {
- File jarFile = new File(jarPath);
- String jarName = jarFile.getName();
+ String jarName =
requireNonNull(java.nio.file.Path.of(jarPath).getFileName()).toString();
try {
fs.copyFromLocalFile(new Path(jarPath), new Path(dfsDestDir));
} catch (IOException e) {
@@ -486,7 +485,7 @@ public class FluoAdminImpl implements FluoAdmin {
StringBuilder jars = new StringBuilder();
for (String path : paths) {
- java.nio.file.Path name = Paths.get(path).getFileName();
+ var name = java.nio.file.Path.of(path).getFileName();
if (name != null) {
String jarName = name.toString();
if (pattern.matcher(jarName).matches()) {
@@ -512,8 +511,7 @@ public class FluoAdminImpl implements FluoAdmin {
}
private static int numOracles(CuratorFramework curator) {
- try {
- LeaderLatch leaderLatch = new LeaderLatch(curator,
ZookeeperPath.ORACLE_SERVER);
+ try (LeaderLatch leaderLatch = new LeaderLatch(curator,
ZookeeperPath.ORACLE_SERVER)) {
return leaderLatch.getParticipants().size();
} catch (Exception e) {
throw new RuntimeException(e);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/client/FluoClientImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/client/FluoClientImpl.java
index 797f7ffb..c70e5757 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoClientImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoClientImpl.java
@@ -15,14 +15,11 @@
package org.apache.fluo.core.client;
-import java.util.Collection;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.fluo.api.client.FluoClient;
import org.apache.fluo.api.client.LoaderExecutor;
import org.apache.fluo.api.client.Snapshot;
@@ -40,7 +37,7 @@ import org.slf4j.LoggerFactory;
/**
* Implementation of Fluo Client
*/
-public class FluoClientImpl implements FluoClient {
+public final class FluoClientImpl implements FluoClient {
private static final Logger log =
LoggerFactory.getLogger(FluoClientImpl.class);
private static final AtomicInteger reporterCounter = new AtomicInteger(1);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/client/LoaderExecutorAsyncImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/client/LoaderExecutorAsyncImpl.java
index 95c123b5..88d4faee 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/client/LoaderExecutorAsyncImpl.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/client/LoaderExecutorAsyncImpl.java
@@ -38,7 +38,7 @@ import org.apache.fluo.core.util.Counter;
import org.apache.fluo.core.util.FluoExecutors;
import org.slf4j.LoggerFactory;
-public class LoaderExecutorAsyncImpl implements LoaderExecutor {
+public final class LoaderExecutorAsyncImpl implements LoaderExecutor {
private final ExecutorService executor;
private final Semaphore semaphore;
private final int semaphoreSize;
@@ -159,9 +159,9 @@ public class LoaderExecutorAsyncImpl implements
LoaderExecutor {
private class QueueReleaseRunnable implements Runnable {
- LoaderCommitObserver loaderTask;
+ LoaderCommitObserver<?> loaderTask;
- QueueReleaseRunnable(LoaderCommitObserver loaderTask) {
+ QueueReleaseRunnable(LoaderCommitObserver<?> loaderTask) {
this.loaderTask = loaderTask;
}
@@ -224,7 +224,7 @@ public class LoaderExecutorAsyncImpl implements
LoaderExecutor {
try {
commiting.increment();
- executor.execute(new QueueReleaseRunnable(new
LoaderCommitObserver(alias, loader)));
+ executor.execute(new QueueReleaseRunnable(new
LoaderCommitObserver<>(alias, loader)));
} catch (RejectedExecutionException rje) {
semaphore.release();
commiting.decrement();
@@ -253,7 +253,7 @@ public class LoaderExecutorAsyncImpl implements
LoaderExecutor {
try {
commiting.increment();
- executor.execute(new QueueReleaseRunnable(new
LoaderCommitObserver(alias, loader, future)));
+ executor.execute(new QueueReleaseRunnable(new
LoaderCommitObserver<>(alias, loader, future)));
} catch (RejectedExecutionException rje) {
semaphore.release();
commiting.decrement();
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java
index 9c35743e..defd11ee 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/Environment.java
@@ -18,14 +18,10 @@ package org.apache.fluo.core.impl;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
-import java.util.List;
import java.util.Map.Entry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -170,7 +166,6 @@ public class Environment implements AutoCloseable {
}
}
-
public void setAuthorizations(Authorizations auths) {
this.auths = auths;
@@ -265,4 +260,12 @@ public class Environment implements AutoCloseable {
resources.close();
client.close();
}
+
+ // CHECKSTYLE:OFF: NoFinalizer
+ @Override
+ public final void finalize() {
+ // prevent CT_CONSTRUCTOR_THROW spotbugs warning about finalizer attacks
+ }
+ // CHECKSTYLE:ON: NoFinalizer
+
}
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/LockResolver.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/LockResolver.java
index 33f8487b..e8da1a0d 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/LockResolver.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/LockResolver.java
@@ -179,13 +179,13 @@ public class LockResolver {
Set<Entry<PrimaryRowColumn, List<LockInfo>>> es = groupedLocks.entrySet();
for (Entry<PrimaryRowColumn, List<LockInfo>> group : es) {
TxInfo txInfo = txiCache.getTransactionInfo(group.getKey());
- switch (txInfo.status) {
+ switch (txInfo.getStatus()) {
case COMMITTED:
- commitColumns(env, group.getKey(), group.getValue(),
txInfo.commitTs, mutations);
+ commitColumns(env, group.getKey(), group.getValue(),
txInfo.getCommitTs(), mutations);
numResolved += group.getValue().size();
break;
case LOCKED:
- if (rollbackPrimary(env, startTs, group.getKey(), txInfo.lockValue))
{
+ if (rollbackPrimary(env, startTs, group.getKey(),
txInfo.getLockValue())) {
rollback(env, startTs, group.getKey(), group.getValue(),
mutations);
numResolved += group.getValue().size();
}
@@ -198,7 +198,7 @@ public class LockResolver {
case UNKNOWN:
default:
throw new IllegalStateException(
- "can not abort : " + group.getKey() + " (" + txInfo.status +
")");
+ "can not abort : " + group.getKey() + " (" + txInfo.getStatus()
+ ")");
}
}
@@ -317,7 +317,6 @@ public class LockResolver {
}
}
-
try (BatchScanner bscanner =
env.getAccumuloClient().createBatchScanner(env.getTable(),
env.getAuthorizations(), 1)) {
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/SharedResources.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/SharedResources.java
index d1211076..4629df59 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/SharedResources.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/SharedResources.java
@@ -38,7 +38,7 @@ import org.apache.fluo.core.util.FluoExecutors;
/**
* Shared Fluo resources that must be closed
*/
-public class SharedResources implements AutoCloseable {
+public final class SharedResources implements AutoCloseable {
private final Environment env;
private final BatchWriter bw;
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/SnapshotScanner.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/SnapshotScanner.java
index 71c46d27..ecca2f63 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/SnapshotScanner.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/SnapshotScanner.java
@@ -102,7 +102,7 @@ public class SnapshotScanner implements Iterable<Entry<Key,
Value>> {
scanner.addScanIterator(iterConf);
}
- private class SnapIter implements Iterator<Entry<Key, Value>> {
+ private final class SnapIter implements Iterator<Entry<Key, Value>> {
private Iterator<Entry<Key, Value>> iterator;
private Entry<Key, Value> next;
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java
index 6b6f37fe..3a5c2383 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java
@@ -27,17 +27,20 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
+import java.util.Spliterators;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
+import com.google.common.collect.MoreCollectors;
import com.google.common.collect.Sets;
import org.apache.accumulo.core.client.ConditionalWriter;
import org.apache.accumulo.core.client.ConditionalWriter.Result;
@@ -887,7 +890,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
return next;
}
-
CompletableFuture<Void> compose(CommitData cd) {
return getMainOp(cd).thenComposeAsync(successful -> {
if (successful) {
@@ -957,7 +959,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
}, ace);
}
-
}
class LockPrimaryStep extends ConditionalStep {
@@ -978,7 +979,7 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
while (mutationStatus == Status.UNKNOWN) {
TxInfo txInfo = TxInfo.getTransactionInfo(env, cd.prow, cd.pcol,
startTs);
- switch (txInfo.status) {
+ switch (txInfo.getStatus()) {
case LOCKED:
return Collections
.singleton(
@@ -1001,7 +1002,7 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
case COMMITTED:
default:
throw new IllegalStateException(
- "unexpected tx state " + txInfo.status + " " + cd.prow + " " +
cd.pcol);
+ "unexpected tx state " + txInfo.getStatus() + " " + cd.prow +
" " + cd.pcol);
}
}
@@ -1012,7 +1013,8 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
@Override
public boolean processResults(CommitData cd, Iterator<Result> results)
throws Exception {
- Result result = Iterators.getOnlyElement(results);
+ Result result =
StreamSupport.stream(Spliterators.spliteratorUnknownSize(results, 0), false)
+ .collect(MoreCollectors.onlyElement());
return result.getStatus() == Status.ACCEPTED;
}
@@ -1020,7 +1022,8 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
CompletableFuture<Void> getFailureOp(CommitData cd) {
// TODO can this be simplified by pushing some code to the superclass?
return CompletableFuture.supplyAsync(() -> {
- final ConditionalMutation pcm =
Iterables.getOnlyElement(createMutations(cd));
+ final ConditionalMutation pcm =
+ createMutations(cd).stream().collect(MoreCollectors.onlyElement());
cd.addPrimaryToRejected();
getStats().setRejected(cd.getRejected());
@@ -1049,7 +1052,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
return cd.bacw;
}
-
@Override
public Collection<ConditionalMutation> createMutations(CommitData cd) {
@@ -1128,8 +1130,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
}
}
-
-
private CompletableFuture<Void> rollbackLocks(CommitData cd) {
CommitStep firstStep = new RollbackOtherLocks();
firstStep.andThen(new RollbackPrimaryLock());
@@ -1139,7 +1139,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
}
-
class RollbackOtherLocks extends BatchWriterStep {
@Override
@@ -1331,7 +1330,8 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
// the code for handing this is synchronous and needs to be handled in
another thread pool
// TODO - how do we do the above without return a CF?
long commitTs = getStats().getCommitTs();
- Result result = Iterators.getOnlyElement(results);
+ Result result =
StreamSupport.stream(Spliterators.spliteratorUnknownSize(results, 0), false)
+ .collect(MoreCollectors.onlyElement());
Status ms = result.getStatus();
while (ms == Status.UNKNOWN) {
@@ -1339,11 +1339,11 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
// TODO async
TxInfo txInfo = TxInfo.getTransactionInfo(env, cd.prow, cd.pcol,
startTs);
- switch (txInfo.status) {
+ switch (txInfo.getStatus()) {
case COMMITTED:
- if (txInfo.commitTs != commitTs) {
+ if (txInfo.getCommitTs() != commitTs) {
throw new IllegalStateException(
- cd.prow + " " + cd.pcol + " " + txInfo.commitTs + "!=" +
commitTs);
+ cd.prow + " " + cd.pcol + " " + txInfo.getCommitTs() + "!="
+ commitTs);
}
ms = Status.ACCEPTED;
break;
@@ -1391,7 +1391,6 @@ public class TransactionImpl extends
AbstractTransactionBase implements AsyncTra
return true;
}
-
class DeleteLocksStep extends BatchWriterStep {
@Override
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
index 878b2f05..3f7561d9 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
/**
* Provides cache of all Fluo transactors. Used by clients to determine if
transactor is running.
*/
-public class TransactorCache implements AutoCloseable {
+public final class TransactorCache implements AutoCloseable {
public enum TcStatus {
OPEN, CLOSED
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorID.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorID.java
index a2b2d299..6c0dd42f 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorID.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorID.java
@@ -28,7 +28,7 @@ import org.apache.fluo.accumulo.util.ZookeeperPath;
* Identifier allocated from Zookeeper that uniquely identifies a transactor.
A transactor is any
* client the performs transactions in Fluo
*/
-public class TransactorID {
+public final class TransactorID {
private final Long id;
diff --git a/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java
index 2b6126dc..8ff45268 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java
@@ -30,9 +30,21 @@ import org.apache.fluo.api.data.Column;
import org.apache.fluo.core.util.ColumnUtil;
public class TxInfo {
- public TxStatus status = null;
- public long commitTs = -1;
- public byte[] lockValue = null;
+ private TxStatus status = null;
+ private long commitTs = -1;
+ private byte[] lockValue = null;
+
+ public TxStatus getStatus() {
+ return status;
+ }
+
+ public long getCommitTs() {
+ return commitTs;
+ }
+
+ public byte[] getLockValue() {
+ return lockValue;
+ }
/**
* determine the what state a transaction is in by inspecting the primary
column
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfoCache.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfoCache.java
index 3947c5c7..549b98c6 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfoCache.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfoCache.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -29,7 +29,7 @@ public class TxInfoCache {
private static class TxStatusWeigher implements Weigher<PrimaryRowColumn,
TxInfo> {
@Override
public int weigh(PrimaryRowColumn key, TxInfo value) {
- return key.weight() + (value.lockValue == null ? 0 :
value.lockValue.length) + 24;
+ return key.weight() + (value.getLockValue() == null ? 0 :
value.getLockValue().length) + 24;
}
}
@@ -55,7 +55,7 @@ public class TxInfoCache {
TxInfo txInfo = cache.getIfPresent(key);
if (txInfo == null) {
txInfo = TxInfo.getTransactionInfo(env, key.prow, key.pcol, key.startTs);
- if (txInfo.status == TxStatus.ROLLED_BACK || txInfo.status ==
TxStatus.COMMITTED) {
+ if (txInfo.getStatus() == TxStatus.ROLLED_BACK || txInfo.getStatus() ==
TxStatus.COMMITTED) {
// only cache for these statuses which are not expected to change,
other status can change
// over time
cache.put(key, txInfo);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/metrics/MetricsUtil.java
b/modules/core/src/main/java/org/apache/fluo/core/metrics/MetricsUtil.java
index 8e64ccef..cda49049 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/metrics/MetricsUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/metrics/MetricsUtil.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -29,8 +29,9 @@ public class MetricsUtil {
String clazz =
config.getString(FluoConfigurationImpl.METRICS_RESERVOIR_PROP,
HdrHistogramResetOnSnapshotReservoir.class.getName());
try {
- return Class.forName(clazz).asSubclass(Reservoir.class).newInstance();
- } catch (InstantiationException | IllegalAccessException |
ClassNotFoundException e) {
+ return
Class.forName(clazz).asSubclass(Reservoir.class).getDeclaredConstructor()
+ .newInstance();
+ } catch (ReflectiveOperationException e) {
throw new IllegalStateException(e);
}
}
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/metrics/starters/CsvReporterStarter.java
b/modules/core/src/main/java/org/apache/fluo/core/metrics/starters/CsvReporterStarter.java
index 824561db..645de3c7 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/metrics/starters/CsvReporterStarter.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/metrics/starters/CsvReporterStarter.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -15,7 +15,7 @@
package org.apache.fluo.core.metrics.starters;
-import java.io.File;
+import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -46,7 +46,7 @@ public class CsvReporterStarter implements ReporterStarter {
TimeUnit.valueOf(config.getString("durationUnit",
"milliseconds").toUpperCase());
CsvReporter reporter = CsvReporter.forRegistry(params.getMetricRegistry())
- .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).build(new
File(dir));
+
.convertDurationsTo(durationUnit).convertRatesTo(rateUnit).build(Path.of(dir).toFile());
reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);
log.info("Reporting metrics as csv to directory {}", dir);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/observer/v1/ObserversV1.java
b/modules/core/src/main/java/org/apache/fluo/core/observer/v1/ObserversV1.java
index 84fa507f..90119f17 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/observer/v1/ObserversV1.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/observer/v1/ObserversV1.java
@@ -19,9 +19,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
+import java.util.function.BiConsumer;
-import com.google.common.collect.Iterables;
import org.apache.fluo.api.data.Column;
import org.apache.fluo.api.observer.Observer;
import org.apache.fluo.core.impl.Environment;
@@ -60,17 +59,18 @@ class ObserversV1 implements Observers {
this.weakObservers = weakObservers;
this.aliases = new HashMap<>();
- for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> e :
Iterables
- .concat(strongObservers.entrySet(), weakObservers.entrySet())) {
- org.apache.fluo.api.config.ObserverSpecification observerConfig =
e.getValue();
- try {
- String alias =
-
Class.forName(observerConfig.getClassName()).asSubclass(Observer.class).getSimpleName();
- aliases.put(e.getKey(), alias);
- } catch (ClassNotFoundException e1) {
- throw new RuntimeException(e1);
- }
- }
+ BiConsumer<Column, org.apache.fluo.api.config.ObserverSpecification>
consumer =
+ (key, observerConfig) -> {
+ try {
+ var alias =
Class.forName(observerConfig.getClassName()).asSubclass(Observer.class)
+ .getSimpleName();
+ aliases.put(key, alias);
+ } catch (ClassNotFoundException e1) {
+ throw new RuntimeException(e1);
+ }
+ };
+ strongObservers.forEach(consumer);
+ weakObservers.forEach(consumer);
}
@Override
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserverStoreV2.java
b/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserverStoreV2.java
index c5731d87..27f06b7d 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserverStoreV2.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserverStoreV2.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -81,13 +81,13 @@ public class ObserverStoreV2 implements ObserverStore {
static ObserverProvider newObserverProvider(String obsProviderClass) {
ObserverProvider observerProvider;
try {
- observerProvider =
-
Class.forName(obsProviderClass).asSubclass(ObserverProvider.class).newInstance();
+ observerProvider =
Class.forName(obsProviderClass).asSubclass(ObserverProvider.class)
+ .getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e1) {
throw new FluoException("ObserverProvider class '" + obsProviderClass +
"' was not "
+ "found. Check for class name misspellings or failure to include "
+ "the observer provider jar.", e1);
- } catch (InstantiationException | IllegalAccessException e2) {
+ } catch (ReflectiveOperationException e2) {
throw new FluoException(
"ObserverProvider class '" + obsProviderClass + "' could not be
created.", e2);
}
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserversV2.java
b/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserversV2.java
index 4eac87f1..71f3c36f 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserversV2.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserversV2.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -28,7 +28,7 @@ import org.apache.fluo.core.impl.Environment;
import org.apache.fluo.core.observer.Observers;
import org.apache.fluo.core.util.Hex;
-class ObserversV2 implements Observers {
+final class ObserversV2 implements Observers {
Map<Column, Observer> observers;
Map<Column, String> aliases;
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/oracle/FluoOracleImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/oracle/FluoOracleImpl.java
index e04b1743..f00721d9 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/FluoOracleImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/FluoOracleImpl.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -16,6 +16,7 @@
package org.apache.fluo.core.oracle;
import java.io.File;
+import java.nio.file.Path;
import java.util.Objects;
import com.google.common.base.Preconditions;
@@ -31,7 +32,7 @@ import org.apache.fluo.core.util.UtilWaitThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FluoOracleImpl implements FluoOracle {
+public final class FluoOracleImpl implements FluoOracle {
private static final Logger log =
LoggerFactory.getLogger(FluoOracleImpl.class);
@@ -92,7 +93,7 @@ public class FluoOracleImpl implements FluoOracle {
}
String propsPath = args[0];
Objects.requireNonNull(propsPath);
- File propsFile = new File(propsPath);
+ File propsFile = Path.of(propsPath).toFile();
if (!propsFile.exists()) {
System.err.println("ERROR - Fluo properties file does not exist: " +
propsPath);
System.exit(-1);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
index e9547cf8..87935e97 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleClient.java
@@ -42,6 +42,7 @@ import org.apache.fluo.core.metrics.MetricsUtil;
import org.apache.fluo.core.thrift.OracleService;
import org.apache.fluo.core.thrift.Stamps;
import org.apache.fluo.core.util.CuratorUtil;
+import org.apache.fluo.core.util.DeprecationUtil;
import org.apache.fluo.core.util.UtilWaitThread;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
@@ -108,7 +109,7 @@ public class OracleClient implements AutoCloseable {
pathChildrenCache =
new PathChildrenCache(curatorFramework,
ZookeeperPath.ORACLE_SERVER, true);
- pathChildrenCache.getListenable().addListener(this);
+ DeprecationUtil.addListener(pathChildrenCache.getListenable(), this);
pathChildrenCache.start();
connect();
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
index 92a822da..8770ef2b 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
@@ -45,6 +45,7 @@ import org.apache.fluo.core.metrics.MetricsUtil;
import org.apache.fluo.core.thrift.OracleService;
import org.apache.fluo.core.thrift.Stamps;
import org.apache.fluo.core.util.CuratorUtil;
+import org.apache.fluo.core.util.DeprecationUtil;
import org.apache.fluo.core.util.FluoThreadFactory;
import org.apache.fluo.core.util.Halt;
import org.apache.fluo.core.util.HostUtil;
@@ -91,7 +92,7 @@ public class OracleServer implements OracleService.Iface,
PathChildrenCacheListe
private volatile long currentTs = 0;
private volatile long maxTs = 0;
private volatile boolean started = false;
- private int port = 0;
+ private volatile int port = 0;
private LeaderLatch leaderLatch;
private ExecutorService execService;
@@ -345,7 +346,7 @@ public class OracleServer implements OracleService.Iface,
PathChildrenCacheListe
leaderLatch.start();
pathChildrenCache = new PathChildrenCache(curatorFramework, oraclePath,
true);
- pathChildrenCache.getListenable().addListener(this);
+ DeprecationUtil.addListener(pathChildrenCache.getListenable(), this);
pathChildrenCache.start();
while (!cnxnListener.isConnected()) {
@@ -410,7 +411,7 @@ public class OracleServer implements OracleService.Iface,
PathChildrenCacheListe
currentLeader = null;
if (curatorFramework.getState().equals(CuratorFrameworkState.STARTED)) {
- pathChildrenCache.getListenable().removeListener(this);
+ DeprecationUtil.removeListener(pathChildrenCache.getListenable(),
this);
pathChildrenCache.close();
leaderLatch.close();
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
b/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
index 07db1b86..305730be 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
@@ -192,7 +192,7 @@ public class CuratorUtil {
final String uuid = new String(uuidBytes, StandardCharsets.UTF_8);
final NodeCache nodeCache = new NodeCache(curator,
ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
- nodeCache.getListenable().addListener(() -> {
+ DeprecationUtil.addListener(nodeCache.getListenable(), () -> {
ChildData node = nodeCache.getCurrentData();
if (node == null || !uuid.equals(new String(node.getData(),
StandardCharsets.UTF_8))) {
Halt.halt("Fluo Application UUID has changed or disappeared");
diff --git a/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
b/modules/core/src/main/java/org/apache/fluo/core/util/DeprecationUtil.java
similarity index 62%
copy from modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
copy to
modules/core/src/main/java/org/apache/fluo/core/util/DeprecationUtil.java
index 824a14e2..2c9ce580 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/client/Snapshot.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/DeprecationUtil.java
@@ -4,31 +4,28 @@
* 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
- *
+ *
* http://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.fluo.api.client;
+package org.apache.fluo.core.util;
-import java.util.Collection;
+public class DeprecationUtil {
-/**
- * Allows users to read from a Fluo table at a certain point in time. Snapshot
extends
- * {@link SnapshotBase} to include a {@link #close} method which must be
called when you are
- * finished using it.
- *
- * @since 1.0.0
- */
-public interface Snapshot extends SnapshotBase, AutoCloseable {
+ @SuppressWarnings("deprecation")
+ public static <T> void addListener(
+ org.apache.curator.framework.listen.ListenerContainer<T> container, T
listener) {
+ container.addListener(listener);
+ }
- /**
- * Closes resources
- */
- @Override
- void close();
+ @SuppressWarnings("deprecation")
+ public static <T> void removeListener(
+ org.apache.curator.framework.listen.ListenerContainer<T> container, T
listener) {
+ container.removeListener(listener);
+ }
}
diff --git a/modules/core/src/main/java/org/apache/fluo/core/util/Limit.java
b/modules/core/src/main/java/org/apache/fluo/core/util/Limit.java
index e53f62c6..61c7840d 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/Limit.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/Limit.java
@@ -23,16 +23,16 @@ import com.google.common.base.Preconditions;
*
*/
public class Limit {
- int permits;
+ int numPermits;
int leased = 0;
- public Limit(int permits) {
- this.permits = permits;
+ public Limit(int numPermits) {
+ this.numPermits = numPermits;
}
public synchronized void acquire(int num) {
Preconditions.checkArgument(num >= 0, "num < 0 : %s", num);
- while (leased >= permits) {
+ while (leased >= numPermits) {
try {
wait();
} catch (InterruptedException e) {
@@ -41,7 +41,7 @@ public class Limit {
}
leased += num;
- if (leased < permits) {
+ if (leased < numPermits) {
notify();
}
}
@@ -50,7 +50,7 @@ public class Limit {
public synchronized void release(int num) {
Preconditions.checkArgument(num <= leased, "relasing more than leased %s >
%s", num, leased);
leased -= num;
- if (leased < permits) {
+ if (leased < numPermits) {
notify();
}
}
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/util/PortUtils.java
b/modules/core/src/main/java/org/apache/fluo/core/util/PortUtils.java
index e42232f2..adc01bd9 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/PortUtils.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/PortUtils.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -17,14 +17,14 @@ package org.apache.fluo.core.util;
import java.io.IOException;
import java.net.ServerSocket;
-import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
public class PortUtils {
private PortUtils() {}
public static int getRandomFreePort() {
- Random r = new Random();
+ var r = ThreadLocalRandom.current();
int count = 0;
while (count < 13) {
diff --git a/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
b/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
index 76282743..e7af6d8f 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
-import com.google.common.collect.Iterables;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -105,7 +104,6 @@ public class ScanUtil {
return columns;
}
-
private static Function<Bytes, String> getEncoder(ScanOpts options) {
if (options.hexEncNonAscii) {
return Hex::encNonAscii;
@@ -114,7 +112,6 @@ public class ScanUtil {
}
}
-
private static void scan(ScanOpts options, PrintStream out, CellScanner
cellScanner) {
Function<Bytes, String> encoder = getEncoder(options);
@@ -219,9 +216,7 @@ public class ScanUtil {
}
}
- for (String entry : Iterables.transform(scanner,
FluoFormatter::toString)) {
- out.println(entry);
- }
+ scanner.stream().map(FluoFormatter::toString).forEach(out::println);
out.flush();
} catch (Exception e) {
throw new RuntimeException(e);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/worker/FluoWorkerImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/worker/FluoWorkerImpl.java
index f95d0b0b..58010e88 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/worker/FluoWorkerImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/worker/FluoWorkerImpl.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -16,6 +16,7 @@
package org.apache.fluo.core.worker;
import java.io.File;
+import java.nio.file.Path;
import java.util.Objects;
import com.google.common.base.Preconditions;
@@ -89,7 +90,7 @@ public class FluoWorkerImpl implements FluoWorker {
}
String propsPath = args[0];
Objects.requireNonNull(propsPath);
- File propsFile = new File(propsPath);
+ File propsFile = Path.of(propsPath).toFile();
if (!propsFile.exists()) {
System.err.println("ERROR - Fluo properties file does not exist: " +
propsPath);
System.exit(-1);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationFinderFactory.java
b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationFinderFactory.java
index 5c58e113..bbbc2644 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationFinderFactory.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationFinderFactory.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -24,8 +24,9 @@ public class NotificationFinderFactory {
String clazz = conf.getString(FluoConfigurationImpl.WORKER_FINDER_PROP,
PartitionNotificationFinder.class.getName());
try {
- return
Class.forName(clazz).asSubclass(NotificationFinder.class).newInstance();
- } catch (InstantiationException | IllegalAccessException |
ClassNotFoundException e) {
+ return
Class.forName(clazz).asSubclass(NotificationFinder.class).getDeclaredConstructor()
+ .newInstance();
+ } catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
index ea452a02..99f3ee80 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -39,7 +39,7 @@ import org.apache.fluo.core.util.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NotificationProcessor implements AutoCloseable {
+public final class NotificationProcessor implements AutoCloseable {
private static final Logger log =
LoggerFactory.getLogger(NotificationProcessor.class);
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/worker/finder/hash/PartitionManager.java
b/modules/core/src/main/java/org/apache/fluo/core/worker/finder/hash/PartitionManager.java
index e106d085..50186f1b 100644
---
a/modules/core/src/main/java/org/apache/fluo/core/worker/finder/hash/PartitionManager.java
+++
b/modules/core/src/main/java/org/apache/fluo/core/worker/finder/hash/PartitionManager.java
@@ -48,6 +48,7 @@ import org.apache.fluo.core.impl.Environment;
import org.apache.fluo.core.impl.FluoConfigurationImpl;
import org.apache.fluo.core.impl.Notification;
import org.apache.fluo.core.util.ByteUtil;
+import org.apache.fluo.core.util.DeprecationUtil;
import org.apache.fluo.core.util.FluoThreadFactory;
import org.apache.zookeeper.CreateMode;
import org.slf4j.Logger;
@@ -67,7 +68,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
* notifications. This limitation is important for scaling, even if there are
1,000 workers there
* will never be more than 7 to 13 workers scanning a portion of the table.
*/
-public class PartitionManager {
+public final class PartitionManager {
private static final Logger log =
LoggerFactory.getLogger(PartitionManager.class);
@@ -285,7 +286,7 @@ public class PartitionManager {
myESNode.waitForInitialCreate(1, TimeUnit.MINUTES);
childrenCache = new PathChildrenCache(curator, ZookeeperPath.FINDERS,
true);
- childrenCache.getListenable().addListener(new FindersListener());
+ DeprecationUtil.addListener(childrenCache.getListenable(), new
FindersListener());
childrenCache.start(StartMode.BUILD_INITIAL_CACHE);
schedExecutor = Executors.newScheduledThreadPool(1,
diff --git
a/modules/core/src/test/java/org/apache/fluo/core/worker/finder/hash/HashTest.java
b/modules/core/src/test/java/org/apache/fluo/core/worker/finder/hash/HashTest.java
index 1d1c5a69..5d08573a 100644
---
a/modules/core/src/test/java/org/apache/fluo/core/worker/finder/hash/HashTest.java
+++
b/modules/core/src/test/java/org/apache/fluo/core/worker/finder/hash/HashTest.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -16,6 +16,7 @@
package org.apache.fluo.core.worker.finder.hash;
import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
import com.google.common.math.DoubleMath;
import org.apache.accumulo.core.data.Key;
@@ -33,7 +34,7 @@ public class HashTest {
@Test
public void testHashingConsistency() {
- Random rand = new Random(7);
+ Random rand = ThreadLocalRandom.current();
int count = 0;
diff --git a/modules/integration-tests/pom.xml
b/modules/integration-tests/pom.xml
index 125b1521..14bb0068 100644
--- a/modules/integration-tests/pom.xml
+++ b/modules/integration-tests/pom.xml
@@ -53,6 +53,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-client</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/ITBase.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/ITBase.java
index 7dc0c8b5..34bdc429 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/ITBase.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/ITBase.java
@@ -15,8 +15,9 @@
package org.apache.fluo.integration;
-import java.io.File;
+import java.nio.file.Path;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -49,7 +50,7 @@ public class ITBase {
protected static String instanceName;
protected static AccumuloClient aClient;
private static MiniAccumuloCluster cluster;
- private static boolean startedCluster = false;
+ private static AtomicBoolean startedCluster = new AtomicBoolean(false);
protected static FluoConfiguration config;
protected static FluoClient client;
@@ -73,7 +74,7 @@ public class ITBase {
@BeforeClass
public static void setUpAccumulo() throws Exception {
instanceName = System.getProperty(IT_INSTANCE_NAME_PROP,
"it-instance-default");
- File instanceDir = new File("target/accumulo2-maven-plugin/" +
instanceName);
+ var instanceDir = Path.of("target/accumulo2-maven-plugin/" +
instanceName).toFile();
boolean instanceClear =
System.getProperty(IT_INSTANCE_CLEAR_PROP,
"true").equalsIgnoreCase("true");
if (instanceDir.exists() && instanceClear) {
@@ -84,7 +85,7 @@ public class ITBase {
cfg.setInstanceName(instanceName);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
- startedCluster = true;
+ startedCluster.set(true);
}
Properties props = MiniAccumuloCluster.getClientProperties(instanceDir);
aClient = Accumulo.newClient().from(props).build();
@@ -131,7 +132,7 @@ public class ITBase {
aClient.close();
}
- if (startedCluster) {
+ if (startedCluster.get()) {
cluster.stop();
}
}
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/TestTransaction.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/TestTransaction.java
index 7d62f486..b959bb60 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/TestTransaction.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/TestTransaction.java
@@ -49,7 +49,7 @@ import org.apache.fluo.core.util.ByteUtil;
import org.apache.fluo.core.util.SpanUtil;
import org.apache.hadoop.io.Text;
-public class TestTransaction extends AbstractTransactionBase implements
TransactionBase {
+public final class TestTransaction extends AbstractTransactionBase implements
TransactionBase {
private TransactionImpl tx;
private Environment env;
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/accumulo/TimeskippingIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/accumulo/TimeskippingIT.java
index 387eed1f..7344770a 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/accumulo/TimeskippingIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/accumulo/TimeskippingIT.java
@@ -17,7 +17,6 @@ package org.apache.fluo.integration.accumulo;
import java.util.Collections;
-import com.google.common.collect.Iterables;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
@@ -25,6 +24,7 @@ import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.security.Authorizations;
+import org.apache.curator.shaded.com.google.common.collect.MoreCollectors;
import org.apache.fluo.accumulo.util.AccumuloProps;
import org.apache.fluo.integration.ITBase;
import org.junit.Assert;
@@ -62,7 +62,8 @@ public class TimeskippingIT extends ITBase {
Scanner scanner = aClient.createScanner("ttsi", Authorizations.EMPTY);
scanner.addScanIterator(new IteratorSetting(10,
Skip100StampsIterator.class));
- Assert.assertEquals("999",
Iterables.getOnlyElement(scanner).getValue().toString());
+ Assert.assertEquals("999",
+
scanner.stream().collect(MoreCollectors.onlyElement()).getValue().toString());
long t3 = System.currentTimeMillis();
if (t3 - t2 > 3000) {
@@ -72,7 +73,8 @@ public class TimeskippingIT extends ITBase {
aClient.tableOperations().flush("ttsi", null, null, true);
long t4 = System.currentTimeMillis();
- Assert.assertEquals("999",
Iterables.getOnlyElement(scanner).getValue().toString());
+ Assert.assertEquals("999",
+
scanner.stream().collect(MoreCollectors.onlyElement()).getValue().toString());
long t5 = System.currentTimeMillis();
if (t5 - t4 > 3000) {
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/client/FluoClientIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/client/FluoClientIT.java
index ff8f094a..1cc8b8bb 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/client/FluoClientIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/client/FluoClientIT.java
@@ -15,15 +15,12 @@
package org.apache.fluo.integration.client;
-import com.google.common.collect.ImmutableList;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.fluo.api.client.FluoClient;
import org.apache.fluo.api.client.FluoFactory;
-import org.apache.fluo.api.client.Snapshot;
import org.apache.fluo.api.client.Transaction;
import org.apache.fluo.api.config.FluoConfiguration;
-import org.apache.fluo.api.data.Bytes;
import org.apache.fluo.api.data.Column;
import org.apache.fluo.api.exceptions.CommitException;
import org.apache.fluo.api.exceptions.FluoException;
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/CollisionIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/CollisionIT.java
index e64a669f..2f40184e 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/CollisionIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/CollisionIT.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -18,8 +18,8 @@ package org.apache.fluo.integration.impl;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
-import com.google.common.collect.Iterables;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
@@ -109,7 +109,7 @@ public class CollisionIT extends ITBaseMini {
@Test
public void testLotsOfCollisions() throws Exception {
- Random rand = new Random(45734985);
+ Random rand = ThreadLocalRandom.current();
int[] nums = new int[1000];
int[] expectedCounts = new int[5];
@@ -166,7 +166,7 @@ public class CollisionIT extends ITBaseMini {
+ String.format("%x", k.getTimestamp() &
ColumnConstants.PREFIX_MASK);
if (rowCols.contains(rowCol)) {
System.err.println("DEBUG oldestTs : " + oldestTS + " recentTS : " +
recentTS);
- Iterables.transform(scanner, e -> "DEBUG " + FluoFormatter.toString(e))
+ scanner.stream().map(e -> "DEBUG " + FluoFormatter.toString(e))
.forEach(System.err::println);
}
Assert.assertFalse("Duplicate row col " + rowCol,
rowCols.contains(rowCol));
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/FailureIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/FailureIT.java
index 8c3c6afd..fa79e698 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/FailureIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/FailureIT.java
@@ -20,12 +20,10 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.CompactionConfig;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.curator.framework.CuratorFramework;
-import org.apache.fluo.accumulo.format.FluoFormatter;
import org.apache.fluo.accumulo.util.ColumnConstants;
import org.apache.fluo.accumulo.util.ColumnType;
import org.apache.fluo.accumulo.util.LongUtil;
@@ -683,6 +681,5 @@ public class FailureIT extends ITBaseImpl {
Assert.assertEquals("60", tx3.gets("jill", ecol));
tx3.close();
-
}
}
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/GarbageCollectionIteratorIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/GarbageCollectionIteratorIT.java
index 03ff986f..fab6d336 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/GarbageCollectionIteratorIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/GarbageCollectionIteratorIT.java
@@ -60,7 +60,6 @@ public class GarbageCollectionIteratorIT extends ITBaseImpl {
}
}
-
public void testVerifyAfterGC() throws Exception {
final TestTransaction tx1 = new TestTransaction(env);
@@ -93,7 +92,6 @@ public class GarbageCollectionIteratorIT extends ITBaseImpl {
tx2.done();
}
-
public void testDeletedDataIsDropped() throws Exception {
final Column docUri = new Column("doc", "uri");
@@ -132,7 +130,6 @@ public class GarbageCollectionIteratorIT extends ITBaseImpl
{
tx4.done();
}
-
public void testRolledBackDataIsDropped() throws Exception {
Column col1 = new Column("fam1", "q1");
@@ -215,7 +212,6 @@ public class GarbageCollectionIteratorIT extends ITBaseImpl
{
String newAltId = (13 * (i + 1)) + "";
String currAltId = tx2.gets(row, altIdCol);
-
tx2.set(row, altIdCol, newAltId);
String count = tx2.gets("a:" + currAltId, new Column("count", row));
@@ -254,22 +250,14 @@ public class GarbageCollectionIteratorIT extends
ITBaseImpl {
waitForGcTime(tx3.getStartTimestamp());
aClient.tableOperations().compact(table, null, null, true, true);
-
// all read locks older than GC time should be dropped
Assert.assertEquals(0, countInTable("-DEL_RLOCK"));
Assert.assertEquals(0, countInTable("-RLOCK"));
}
- private int countInTable(String str) throws TableNotFoundException {
- int count = 0;
- Scanner scanner = aClient.createScanner(table, Authorizations.EMPTY);
- for (String e : Iterables.transform(scanner, FluoFormatter::toString)) {
- if (e.contains(str)) {
- count++;
- }
- }
-
- return count;
+ private long countInTable(String str) throws TableNotFoundException {
+ return aClient.createScanner(table,
Authorizations.EMPTY).stream().map(FluoFormatter::toString)
+ .filter(s -> s.contains(str)).count();
}
@Test
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/MiniIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/MiniIT.java
index 7c070aa2..1fe417cb 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/MiniIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/MiniIT.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -15,7 +15,7 @@
package org.apache.fluo.integration.impl;
-import java.io.File;
+import java.nio.file.Path;
import org.apache.commons.io.FileUtils;
import org.apache.fluo.api.client.FluoClient;
@@ -41,8 +41,8 @@ public class MiniIT {
@Test
public void testMini() throws Exception {
- File dataDir =
- new File(System.getProperty("user.dir") + "/target/" +
MiniIT.class.getSimpleName());
+ var dataDir =
+ Path.of(System.getProperty("user.dir"), "target",
MiniIT.class.getSimpleName()).toFile();
if (dataDir.exists()) {
FileUtils.deleteDirectory(dataDir);
}
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockFailureIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockFailureIT.java
index 7a8b8d29..b681f4c0 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockFailureIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockFailureIT.java
@@ -22,8 +22,6 @@ import java.util.Set;
import java.util.function.Consumer;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.fluo.accumulo.format.FluoFormatter;
@@ -346,16 +344,9 @@ public class ReadLockFailureIT extends ITBaseImpl {
testWriteWoRead(true, true);
}
- private int countInTable(String str) throws TableNotFoundException {
- int count = 0;
- Scanner scanner = aClient.createScanner(table, Authorizations.EMPTY);
- for (String e : Iterables.transform(scanner, FluoFormatter::toString)) {
- if (e.contains(str)) {
- count++;
- }
- }
-
- return count;
+ private long countInTable(String str) throws TableNotFoundException {
+ return aClient.createScanner(table,
Authorizations.EMPTY).stream().map(FluoFormatter::toString)
+ .filter(s -> s.contains(str)).count();
}
@Test
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockIT.java
index d6dc7175..292dc111 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ReadLockIT.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -127,7 +126,6 @@ public class ReadLockIT extends ITBaseImpl {
tx.commit();
}
-
TestTransaction tx1 = new TestTransaction(env);
setAlias(tx1, "node2", "jojo");
@@ -321,7 +319,7 @@ public class ReadLockIT extends ITBaseImpl {
Set<String> actualEdges = getDerivedEdges();
if (!expectedEdges.equals(actualEdges)) {
- Path dumpFile = Paths.get("target/ReadLockIT.txt");
+ Path dumpFile = Path.of("target/ReadLockIT.txt");
try (BufferedWriter writer = Files.newBufferedWriter(dumpFile)) {
@@ -334,7 +332,6 @@ public class ReadLockIT extends ITBaseImpl {
}
};
-
writer.append("Alias changes : \n");
Maps.difference(nodes, nodes2).entriesDiffering()
.forEach((k, v) -> out.accept(k + " " + v));
@@ -369,7 +366,6 @@ public class ReadLockIT extends ITBaseImpl {
setAlias(tx, "node1", "bob");
setAlias(tx, "node2", "joe");
-
tx.commit();
}
@@ -410,7 +406,6 @@ public class ReadLockIT extends ITBaseImpl {
txi.commit();
}
-
List<Consumer<TransactionBase>> writeLockOperations = ImmutableList.of(txw
-> {
txw.set("test1", c1, "47");
}, txw -> {
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ScannerIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ScannerIT.java
index e5a8d023..9c4d0f7c 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ScannerIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/ScannerIT.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -19,7 +19,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import com.google.common.collect.Iterables;
import org.apache.fluo.api.client.Snapshot;
import org.apache.fluo.api.client.Transaction;
import org.apache.fluo.api.client.scanner.CellScanner;
@@ -35,6 +34,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
+import static java.util.stream.Collectors.toSet;
+
public class ScannerIT extends ITBaseImpl {
@Rule
public Timeout globalTimeout = Timeout.seconds(getTestTimeout());
@@ -43,51 +44,44 @@ public class ScannerIT extends ITBaseImpl {
public void testFiltering() {
Set<RowColumnValue> expected = genData();
- HashSet<RowColumnValue> expectedR2 = new HashSet<>();
- Iterables.addAll(expectedR2, Iterables.filter(expected, rcv ->
rcv.getsRow().equals("r2")));
+ Set<RowColumnValue> expectedR2 =
+ expected.stream().filter(rcv ->
rcv.getsRow().equals("r2")).collect(toSet());
Assert.assertEquals(2, expectedR2.size());
- HashSet<RowColumnValue> expectedR2c = new HashSet<>();
- Iterables.addAll(expectedR2c, Iterables.filter(expected,
- rcv -> rcv.getsRow().equals("r2") && rcv.getColumn().equals(new
Column("f1", "q2"))));
+ Set<RowColumnValue> expectedR2c = expected.stream()
+ .filter(rcv -> rcv.getsRow().equals("r2") &&
rcv.getColumn().equals(new Column("f1", "q2")))
+ .collect(toSet());
Assert.assertEquals(1, expectedR2c.size());
- HashSet<RowColumnValue> expectedC = new HashSet<>();
- Iterables.addAll(expectedC,
- Iterables.filter(expected, rcv -> rcv.getColumn().equals(new
Column("f1", "q1"))));
+ Set<RowColumnValue> expectedC = expected.stream()
+ .filter(rcv -> rcv.getColumn().equals(new Column("f1",
"q1"))).collect(toSet());
Assert.assertEquals(2, expectedC.size());
- HashSet<RowColumnValue> expectedCF = new HashSet<>();
- Iterables.addAll(expectedCF,
- Iterables.filter(expected, rcv ->
rcv.getColumn().getsFamily().equals("f2")));
+ Set<RowColumnValue> expectedCF =
+ expected.stream().filter(rcv ->
rcv.getColumn().getsFamily().equals("f2")).collect(toSet());
Assert.assertEquals(2, expectedCF.size());
- HashSet<RowColumnValue> expectedCols = new HashSet<>();
- Iterables.addAll(expectedCols,
- Iterables.filter(expected, rcv -> rcv.getColumn().equals(new
Column("f2", "q5"))
- || rcv.getColumn().equals(new Column("f1", "q1"))));
+ Set<RowColumnValue> expectedCols =
+ expected.stream().filter(rcv -> rcv.getColumn().equals(new
Column("f2", "q5"))
+ || rcv.getColumn().equals(new Column("f1",
"q1"))).collect(toSet());
Assert.assertEquals(3, expectedCols.size());
try (Snapshot snap = client.newSnapshot()) {
- HashSet<RowColumnValue> actual = new HashSet<>();
- Iterables.addAll(actual, snap.scanner().over("r2").build());
+ Set<RowColumnValue> actual =
snap.scanner().over("r2").build().stream().collect(toSet());
Assert.assertEquals(expectedR2, actual);
- actual.clear();
- Iterables.addAll(actual, snap.scanner().over("r2").fetch(new
Column("f1", "q2")).build());
+ actual =
+ snap.scanner().over("r2").fetch(new Column("f1",
"q2")).build().stream().collect(toSet());
Assert.assertEquals(expectedR2c, actual);
- actual.clear();
- Iterables.addAll(actual, snap.scanner().fetch(new Column("f1",
"q1")).build());
+ actual = snap.scanner().fetch(new Column("f1",
"q1")).build().stream().collect(toSet());
Assert.assertEquals(expectedC, actual);
- actual.clear();
- Iterables.addAll(actual, snap.scanner().fetch(new Column("f2")).build());
+ actual = snap.scanner().fetch(new
Column("f2")).build().stream().collect(toSet());
Assert.assertEquals(expectedCF, actual);
- actual.clear();
- Iterables.addAll(actual,
- snap.scanner().fetch(new Column("f2", "q5"), new Column("f1",
"q1")).build());
+ actual = snap.scanner().fetch(new Column("f2", "q5"), new Column("f1",
"q1")).build().stream()
+ .collect(toSet());
Assert.assertEquals(expectedCols, actual);
}
@@ -100,9 +94,9 @@ public class ScannerIT extends ITBaseImpl {
Column col1 = new Column("f1", "q1");
Column col2 = new Column("f2", "q3");
- HashSet<RowColumnValue> expectedC = new HashSet<>();
- Iterables.addAll(expectedC, Iterables.filter(expected,
- rcv -> rcv.getColumn().equals(col1) || rcv.getColumn().equals(col2)));
+ Set<RowColumnValue> expectedC = expected.stream()
+ .filter(rcv -> rcv.getColumn().equals(col1) ||
rcv.getColumn().equals(col2))
+ .collect(toSet());
Assert.assertEquals(3, expectedC.size());
try (Snapshot snap = client.newSnapshot()) {
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/StochasticBankIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/StochasticBankIT.java
index d9c779dc..94327e75 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/StochasticBankIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/StochasticBankIT.java
@@ -15,9 +15,9 @@
package org.apache.fluo.integration.impl;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
+import java.io.IOException;
+import java.io.UncheckedIOException;
import java.io.Writer;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -27,11 +27,10 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.TreeSet;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import com.google.common.collect.Iterables;
-import org.apache.accumulo.core.client.Scanner;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.fluo.accumulo.format.FluoFormatter;
import org.apache.fluo.accumulo.util.AccumuloProps;
@@ -79,7 +78,7 @@ public class StochasticBankIT extends ITBaseImpl {
populate(env, numAccounts);
- Random rand = new Random();
+ Random rand = ThreadLocalRandom.current();
Environment tenv = env;
if (rand.nextBoolean()) {
@@ -123,9 +122,9 @@ public class StochasticBankIT extends ITBaseImpl {
ArrayList<Thread> threads = new ArrayList<>();
+ Random rand = ThreadLocalRandom.current();
for (int i = 0; i < numThreads; i++) {
Runnable task = new Runnable() {
- Random rand = new Random();
@Override
public void run() {
@@ -254,18 +253,17 @@ public class StochasticBankIT extends ITBaseImpl {
log.debug("sum1 : %,d sum2 : %,d diff : %,d\n", sum1, sum2, sum2 - sum1);
File tmpFile = Files.createTempFile("sb_dump", ".txt").toFile();
- Writer fw = new BufferedWriter(new FileWriter(tmpFile));
-
- Scanner scanner =
- env.getAccumuloClient().createScanner(env.getTable(),
env.getAuthorizations());
-
- for (String cell : Iterables.transform(scanner, FluoFormatter::toString)) {
- fw.append(cell);
- fw.append("\n");
+ try (Writer fw = Files.newBufferedWriter(tmpFile.toPath())) {
+ env.getAccumuloClient().createScanner(env.getTable(),
env.getAuthorizations()).stream()
+ .map(FluoFormatter::toString).forEach(cell -> {
+ try {
+ fw.append(cell);
+ fw.append("\n");
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
}
-
- fw.close();
-
log.debug("Dumped table : " + tmpFile);
}
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/log/LogIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/log/LogIT.java
index 52027370..3f94ec89 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/log/LogIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/log/LogIT.java
@@ -51,7 +51,6 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
-import org.slf4j.LoggerFactory;
import static org.apache.fluo.api.observer.Observer.NotificationType.WEAK;
diff --git
a/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java
b/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java
index 3eb701f5..ac35a205 100644
---
a/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java
+++
b/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java
@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormat;
import org.apache.accumulo.hadoopImpl.mapred.RangeInputSplit;
import org.apache.fluo.api.config.FluoConfiguration;
diff --git
a/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoRowInputFormat.java
b/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoRowInputFormat.java
index 710e31d1..fed24598 100644
---
a/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoRowInputFormat.java
+++
b/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoRowInputFormat.java
@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormat;
import org.apache.accumulo.hadoopImpl.mapreduce.RangeInputSplit;
import org.apache.fluo.api.client.scanner.ColumnScanner;
diff --git
a/modules/mapreduce/src/test/java/org/apache/fluo/mapreduce/it/FluoFileOutputFormatIT.java
b/modules/mapreduce/src/test/java/org/apache/fluo/mapreduce/it/FluoFileOutputFormatIT.java
index 5aed6082..bbc0ec42 100644
---
a/modules/mapreduce/src/test/java/org/apache/fluo/mapreduce/it/FluoFileOutputFormatIT.java
+++
b/modules/mapreduce/src/test/java/org/apache/fluo/mapreduce/it/FluoFileOutputFormatIT.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -19,6 +19,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
@@ -28,7 +29,6 @@ import org.apache.fluo.integration.ITBaseImpl;
import org.apache.fluo.integration.TestTransaction;
import org.apache.fluo.mapreduce.FluoKeyValue;
import org.apache.fluo.mapreduce.FluoKeyValueGenerator;
-import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
@@ -62,20 +62,20 @@ public class FluoFileOutputFormatIT extends ITBaseImpl {
@Rule
public TemporaryFolder tempFolder =
- new TemporaryFolder(new File(System.getProperty("user.dir") +
"/target"));
+ new TemporaryFolder(Path.of(System.getProperty("user.dir"),
"target").toFile());
@Test
public void testImportFile() throws Exception {
- File inDir = new File(tempFolder.getRoot(), "in");
+ File inDir = tempFolder.getRoot().toPath().resolve("in").toFile();
Assert.assertTrue(inDir.mkdir());
- File outDir = new File(tempFolder.getRoot(), "out");
- File failDir = new File(tempFolder.getRoot(), "fail");
+ File outDir = tempFolder.getRoot().toPath().resolve("out").toFile();
+ File failDir = tempFolder.getRoot().toPath().resolve("fail").toFile();
Assert.assertTrue(failDir.mkdir());
// generate some data for map reduce to read
PrintWriter writer =
- new PrintWriter(new File(inDir, "file1.txt"),
StandardCharsets.UTF_8.name());
+ new PrintWriter(inDir.toPath().resolve("file1.txt").toFile(),
StandardCharsets.UTF_8);
writer.println("a,b,c,1");
writer.println("d,b,c,2");
writer.println("foo,moo,moo,90");
@@ -90,7 +90,7 @@ public class FluoFileOutputFormatIT extends ITBaseImpl {
job.setInputFormatClass(TextInputFormat.class);
FileInputFormat.setInputPaths(job, inDir.toURI().toString());
job.setOutputFormatClass(AccumuloFileOutputFormat.class);
- AccumuloFileOutputFormat.setOutputPath(job, new Path(outDir.toURI()));
+ AccumuloFileOutputFormat.setOutputPath(job, new
org.apache.hadoop.fs.Path(outDir.toURI()));
job.setMapperClass(TestMapper.class);
job.setNumReduceTasks(0);
Assert.assertTrue(job.waitForCompletion(false));
diff --git a/modules/mini/src/main/java/org/apache/fluo/mini/MiniFluoImpl.java
b/modules/mini/src/main/java/org/apache/fluo/mini/MiniFluoImpl.java
index 5a9f0ca0..33e0d1d4 100644
--- a/modules/mini/src/main/java/org/apache/fluo/mini/MiniFluoImpl.java
+++ b/modules/mini/src/main/java/org/apache/fluo/mini/MiniFluoImpl.java
@@ -4,9 +4,9 @@
* 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
- *
+ *
* http://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
@@ -16,6 +16,7 @@
package org.apache.fluo.mini;
import java.io.File;
+import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -45,7 +46,7 @@ import org.slf4j.LoggerFactory;
/**
* Implementation of MiniFluo
*/
-public class MiniFluoImpl implements MiniFluo {
+public final class MiniFluoImpl implements MiniFluo {
private static final Logger log =
LoggerFactory.getLogger(MiniFluoImpl.class);
@@ -106,7 +107,7 @@ public class MiniFluoImpl implements MiniFluo {
private void startMiniAccumulo() {
try {
// start mini accumulo cluster
- MiniAccumuloConfig cfg = new MiniAccumuloConfig(new
File(config.getMiniDataDir()), PASSWORD);
+ var cfg = new
MiniAccumuloConfig(Path.of(config.getMiniDataDir()).toFile(), PASSWORD);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
@@ -131,7 +132,7 @@ public class MiniFluoImpl implements MiniFluo {
admin.initialize(opts);
}
- File miniProps = new File(clientPropsPath(config));
+ File miniProps = Path.of(clientPropsPath(config)).toFile();
config.getClientConfiguration().save(miniProps);
log.debug("Wrote MiniFluo client properties to {}",
miniProps.getAbsolutePath());
diff --git a/pom.xml b/pom.xml
index 09e78156..c42ee851 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,9 +27,8 @@
<description>An implementation of Percolator for Apache
Accumulo</description>
<licenses>
<license>
- <name>Apache License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0</url>
- <distribution>repo</distribution>
+ <name>Apache-2.0</name>
+ <url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<modules>
@@ -63,11 +62,17 @@
<extraReleaseArguments>-P thrift</extraReleaseArguments>
<!-- Prevent findbugs from runnning because it does not work with Java 11
and is configured to run by parent pom. Spotbugs is configured in place of
findbugs. -->
<findbugs.skip>true</findbugs.skip>
- <hadoop.version>3.3.4</hadoop.version>
+ <hadoop.version>3.4.0</hadoop.version>
+ <maven.compiler.release>11</maven.compiler.release>
+ <maven.compiler.source>${maven.compiler.release}</maven.compiler.source>
+ <maven.compiler.target>${maven.compiler.release}</maven.compiler.target>
+ <maven.min-version>3.6.3</maven.min-version>
+ <!-- versions-maven-plugin ignore patterns for snapshots, alpha, beta,
milestones, and release candidates -->
+
<maven.version.ignore>.+-SNAPSHOT,(?i).*(alpha|beta)[0-9.-]*,(?i).*[.-](m|rc)[0-9]+</maven.version.ignore>
<releaseProfiles>fluo-release</releaseProfiles>
<slf4j.version>2.0.3</slf4j.version>
<thrift.version>0.17.0</thrift.version>
- <zookeeper.version>3.8.4</zookeeper.version>
+ <zookeeper.version>3.9.2</zookeeper.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -106,6 +111,11 @@
<artifactId>metrics-graphite</artifactId>
<version>3.2.6</version>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -258,15 +268,36 @@
<build>
<pluginManagement>
<plugins>
+ <!-- check for version updates with 'mvn
versions:display-plugin-updates' -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>versions-maven-plugin</artifactId>
+ <version>2.18.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <groupId>net.revelc.code</groupId>
+ <artifactId>apilyzer-maven-plugin</artifactId>
+ <version>1.3.0</version>
+ </plugin>
+ <plugin>
+ <groupId>net.revelc.code</groupId>
+ <artifactId>impsort-maven-plugin</artifactId>
+ <version>1.12.0</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>3.0.0-M3</version>
+ <version>3.5.0</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
- <version>4.0.0</version>
+ <version>4.9.3.0</version>
<configuration>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
@@ -286,12 +317,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
+ <version>3.14.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.1.1</version>
+ <version>3.11.2</version>
<configuration>
<doclint>all,-missing</doclint>
</configuration>
@@ -356,6 +387,16 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.6.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.7.1</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
@@ -367,7 +408,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
- <version>1.6.0</version>
+ <version>3.5.0</version>
</plugin>
</plugins>
</pluginManagement>
@@ -397,6 +438,7 @@
<failOnWarning>true</failOnWarning>
<ignoredDependencies>
<ignoredDependency>org.apache.logging.log4j:*</ignoredDependency>
+
<ignoredDependency>org.apache.zookeeper:zookeeper-jute:*</ignoredDependency>
</ignoredDependencies>
</configuration>
</execution>
@@ -462,26 +504,5 @@
<spotbugs.excludeFilterFile>src/main/spotbugs/exclude-filter.xml</spotbugs.excludeFilterFile>
</properties>
</profile>
- <profile>
- <id>m2e-compiler-compliance</id>
- <activation>
- <property>
- <name>m2e.version</name>
- </property>
- </activation>
- <properties>
- <!-- add compiler compliance to Eclipse -->
- <maven.compiler.release>8</maven.compiler.release>
- </properties>
- </profile>
- <profile>
- <id>jdk-release-flag</id>
- <activation>
- <jdk>[9,)</jdk>
- </activation>
- <properties>
- <maven.compiler.release>8</maven.compiler.release>
- </properties>
- </profile>
</profiles>
</project>