You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/26 06:19:49 UTC
[shardingsphere-elasticjob] branch master updated: Replace
com.google.common.base.Charsets.UTF_8 with StandardCharsets.UTF_8 (#1270)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new cd1b1d9 Replace com.google.common.base.Charsets.UTF_8 with StandardCharsets.UTF_8 (#1270)
cd1b1d9 is described below
commit cd1b1d98286531fb6b03e0e8734a00019c79e849
Author: 吴伟杰 <ro...@me.com>
AuthorDate: Sun Jul 26 14:19:40 2020 +0800
Replace com.google.common.base.Charsets.UTF_8 with StandardCharsets.UTF_8 (#1270)
---
.../cloud/scheduler/state/failover/FailoverService.java | 5 +++--
.../reg/zookeeper/ZookeeperRegistryCenter.java | 16 ++++++++--------
.../lite/internal/listener/AbstractJobListener.java | 5 +++--
.../lifecycle/internal/reg/RegistryCenterFactory.java | 6 +++---
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
index 434a3c9..8b5e87d 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover;
-import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
@@ -32,6 +31,7 @@ import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -114,7 +114,8 @@ public final class FailoverService {
List<Integer> result = new ArrayList<>(taskIdList.size());
for (String each : taskIdList) {
MetaInfo metaInfo = MetaInfo.from(each);
- if (assignedTasks.add(Hashing.sha256().newHasher().putString(jobName, Charsets.UTF_8).putInt(metaInfo.getShardingItems().get(0)).hash()) && !runningService.isTaskRunning(metaInfo)) {
+ if (assignedTasks.add(Hashing.sha256().newHasher().putString(jobName, StandardCharsets.UTF_8).putInt(metaInfo.getShardingItems().get(0)).hash())
+ && !runningService.isTaskRunning(metaInfo)) {
result.add(metaInfo.getShardingItems().get(0));
}
}
diff --git a/elasticjob-infra/elasticjob-registry-center/src/main/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenter.java b/elasticjob-infra/elasticjob-registry-center/src/main/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenter.java
index 2fbaad8..c414a0d 100644
--- a/elasticjob-infra/elasticjob-registry-center/src/main/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenter.java
+++ b/elasticjob-infra/elasticjob-registry-center/src/main/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenter.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.reg.zookeeper;
-import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.AccessLevel;
@@ -39,6 +38,7 @@ import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -80,7 +80,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
builder.connectionTimeoutMs(zkConfig.getConnectionTimeoutMilliseconds());
}
if (!Strings.isNullOrEmpty(zkConfig.getDigest())) {
- builder.authorization("digest", zkConfig.getDigest().getBytes(Charsets.UTF_8))
+ builder.authorization("digest", zkConfig.getDigest().getBytes(StandardCharsets.UTF_8))
.aclProvider(new ACLProvider() {
@Override
@@ -138,7 +138,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
}
Optional<ChildData> resultInCache = cache.get(key);
if (resultInCache.isPresent()) {
- return null == resultInCache.get().getData() ? null : new String(resultInCache.get().getData(), Charsets.UTF_8);
+ return null == resultInCache.get().getData() ? null : new String(resultInCache.get().getData(), StandardCharsets.UTF_8);
}
return getDirectly(key);
}
@@ -155,7 +155,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
@Override
public String getDirectly(final String key) {
try {
- return new String(client.getData().forPath(key), Charsets.UTF_8);
+ return new String(client.getData().forPath(key), StandardCharsets.UTF_8);
//CHECKSTYLE:OFF
} catch (final Exception ex) {
//CHECKSTYLE:ON
@@ -209,7 +209,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
public void persist(final String key, final String value) {
try {
if (!isExisted(key)) {
- client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(key, value.getBytes(Charsets.UTF_8));
+ client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(key, value.getBytes(StandardCharsets.UTF_8));
} else {
update(key, value);
}
@@ -224,7 +224,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
public void update(final String key, final String value) {
try {
TransactionOp transactionOp = client.transactionOp();
- client.transaction().forOperations(transactionOp.check().forPath(key), transactionOp.setData().forPath(key, value.getBytes(Charsets.UTF_8)));
+ client.transaction().forOperations(transactionOp.check().forPath(key), transactionOp.setData().forPath(key, value.getBytes(StandardCharsets.UTF_8)));
//CHECKSTYLE:OFF
} catch (final Exception ex) {
//CHECKSTYLE:ON
@@ -238,7 +238,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
if (isExisted(key)) {
client.delete().deletingChildrenIfNeeded().forPath(key);
}
- client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Charsets.UTF_8));
+ client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(StandardCharsets.UTF_8));
//CHECKSTYLE:OFF
} catch (final Exception ex) {
//CHECKSTYLE:ON
@@ -249,7 +249,7 @@ public final class ZookeeperRegistryCenter implements CoordinatorRegistryCenter
@Override
public String persistSequential(final String key, final String value) {
try {
- return client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(key, value.getBytes(Charsets.UTF_8));
+ return client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(key, value.getBytes(StandardCharsets.UTF_8));
//CHECKSTYLE:OFF
} catch (final Exception ex) {
//CHECKSTYLE:ON
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
index 2cab9b2..9756fa0 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/listener/AbstractJobListener.java
@@ -17,10 +17,11 @@
package org.apache.shardingsphere.elasticjob.lite.internal.listener;
-import com.google.common.base.Charsets;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.CuratorCacheListener;
+import java.nio.charset.StandardCharsets;
+
/**
* Job Listener.
*/
@@ -36,7 +37,7 @@ public abstract class AbstractJobListener implements CuratorCacheListener {
if (path.isEmpty()) {
return;
}
- dataChanged(path, type, null == data ? "" : new String(data, Charsets.UTF_8));
+ dataChanged(path, type, null == data ? "" : new String(data, StandardCharsets.UTF_8));
}
protected abstract void dataChanged(String path, Type eventType, String data);
diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactory.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactory.java
index b9c660d..b6f16b8 100644
--- a/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactory.java
+++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/reg/RegistryCenterFactory.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.reg;
-import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hasher;
@@ -28,6 +27,7 @@ import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -47,9 +47,9 @@ public final class RegistryCenterFactory {
* @return registry center
*/
public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final String digest) {
- Hasher hasher = Hashing.sha256().newHasher().putString(connectString, Charsets.UTF_8).putString(namespace, Charsets.UTF_8);
+ Hasher hasher = Hashing.sha256().newHasher().putString(connectString, StandardCharsets.UTF_8).putString(namespace, StandardCharsets.UTF_8);
if (!Strings.isNullOrEmpty(digest)) {
- hasher.putString(digest, Charsets.UTF_8);
+ hasher.putString(digest, StandardCharsets.UTF_8);
}
HashCode hashCode = hasher.hash();
CoordinatorRegistryCenter result = REG_CENTER_REGISTRY.get(hashCode);