chore: clean some comment/code

This commit is contained in:
V_Galaxy 2023-08-07 16:53:08 +08:00 committed by imbajin
parent 1234c110e7
commit 84273f2093
No known key found for this signature in database
GPG Key ID: BA7E78F8A81A885E
67 changed files with 110 additions and 291 deletions

BIN
hugegraph-pd/.DS_Store vendored

Binary file not shown.

View File

@ -21,7 +21,7 @@ touch output/1
export JAVA_HOME=$ORACLEJDK_1_8_0_HOME
readonly VER=3.6.3
readonly REPO_URL=http://10.14.139.8:8081/artifactory/star-local
readonly REPO_URL=http://127.0.0.1:8081/artifactory/star-local
$MAVEN_3_5_3_BIN/mvn -DremoveSnapshot=true -DprocessAllModules=true -DgenerateBackupPoms=true versions:set
$MAVEN_3_5_3_BIN/mvn --settings ./settings.xml -Dmaven.test.skip=true -DaltDeploymentRepository=star-local::default::${REPO_URL} clean deploy
@ -30,7 +30,7 @@ $MAVEN_3_5_3_BIN/mvn versions:revert
#------------------repo-----------------------
readonly FILE_NAME=hugegraph-pd-3.6.3.tar.gz
readonly REPO_URL_FILE=http://10.14.139.8:8081/artifactory/star-file
readonly REPO_URL_FILE=http://127.0.0.1:8081/artifactory/star-file
localFilePath=dist/${FILE_NAME}
targetFolder="${REPO_URL_FILE}/dist/$(date '+%Y-%m-%d')/"

View File

@ -17,7 +17,7 @@
#
readonly VER=3.6.3
readonly REPO_URL=http://10.14.139.8:8081/artifactory/star-local
readonly REPO_URL=http://127.0.0.1:8081/artifactory/star-local
#mvn -DnewVersion=${VER}-SNAPSHOT -DprocessAllModules=true -DgenerateBackupPoms=false versions:set
./mvnw -DremoveSnapshot=true -DprocessAllModules=true -DgenerateBackupPoms=true versions:set

View File

@ -17,7 +17,7 @@
#
readonly VER=3.6.3
readonly REPO_URL=http://10.14.139.8:8081/artifactory/star-local
readonly REPO_URL=http://127.0.0.1:8081/artifactory/star-local
#mvn -DnewVersion=${VER}-SNAPSHOT -DprocessAllModules=true -DgenerateBackupPoms=false versions:set
./mvnw -DremoveSnapshot=true -DprocessAllModules=true -DgenerateBackupPoms=true versions:set

View File

@ -22,9 +22,6 @@ import java.util.LinkedList;
import io.grpc.stub.AbstractBlockingStub;
import io.grpc.stub.AbstractStub;
/**
* @date 2022/6/20
**/
public class AbstractClientStubProxy {
private final LinkedList<String> hostList = new LinkedList<>();

View File

@ -20,9 +20,6 @@ package org.apache.hugegraph.pd.client;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
import org.apache.hugegraph.pd.grpc.discovery.Query;
/**
* @date 2021/12/20
**/
public interface Discoverable {
NodeInfos getNodeInfos(Query query);

View File

@ -38,9 +38,6 @@ import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2021/12/20
**/
@Slf4j
public abstract class DiscoveryClient implements Closeable, Discoverable {
@ -127,20 +124,20 @@ public abstract class DiscoveryClient implements Closeable, Discoverable {
try {
if (requireResetStub.get()) {
while (channel != null && !channel.shutdownNow().awaitTermination(
100, TimeUnit.MILLISECONDS)) {
100, TimeUnit.MILLISECONDS)) {
continue;
}
channel = ManagedChannelBuilder.forTarget(
singleAddress).usePlaintext().build();
singleAddress).usePlaintext().build();
this.registerStub = DiscoveryServiceGrpc.newBlockingStub(
channel);
channel);
this.blockingStub = DiscoveryServiceGrpc.newBlockingStub(
channel);
channel);
requireResetStub.set(false);
}
} catch (Exception e) {
throw new PDException(-1, String.format(
"Reset channel with error : %s.", e.getMessage()));
"Reset channel with error : %s.", e.getMessage()));
} finally {
readWriteLock.writeLock().unlock();
}
@ -212,7 +209,7 @@ public abstract class DiscoveryClient implements Closeable, Discoverable {
readWriteLock.writeLock().lock();
try {
while (channel != null && !channel.shutdownNow().awaitTermination(
100, TimeUnit.MILLISECONDS)) {
100, TimeUnit.MILLISECONDS)) {
continue;
}
} catch (Exception e) {

View File

@ -23,9 +23,6 @@ import java.util.function.Consumer;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfo;
import org.apache.hugegraph.pd.grpc.discovery.RegisterType;
/**
* @date 2021/12/20
**/
public class DiscoveryClientImpl extends DiscoveryClient {
private final String id;

View File

@ -27,9 +27,6 @@ import io.grpc.stub.AbstractBlockingStub;
import io.grpc.stub.AbstractStub;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2022/8/3
**/
@Slf4j
public class LicenseClient extends AbstractClient {

View File

@ -26,8 +26,6 @@ import org.apache.hugegraph.pd.pulse.PulseServerNotice;
/**
* Bidirectional communication interface of pd-client and pd-server
*
* @author lynn.bond@hotmail.com created on 2021/11/9
*/
public interface PDPulse {
@ -151,4 +149,4 @@ public interface PDPulse {
void crash(String error);
}
}
}

View File

@ -38,9 +38,6 @@ import io.grpc.ManagedChannel;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/9
*/
@Slf4j
public final class PDPulseImpl implements PDPulse {

View File

@ -24,9 +24,6 @@ import org.apache.hugegraph.pd.grpc.watch.WatchResponse;
import org.apache.hugegraph.pd.watch.NodeEvent;
import org.apache.hugegraph.pd.watch.PartitionEvent;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
public interface PDWatch {
/**

View File

@ -17,7 +17,6 @@
package org.apache.hugegraph.pd.client;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import org.apache.hugegraph.pd.grpc.watch.HgPdWatchGrpc;
@ -31,17 +30,14 @@ import org.apache.hugegraph.pd.watch.NodeEvent;
import org.apache.hugegraph.pd.watch.PartitionEvent;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.stub.StreamObserver;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
final class PDWatchImpl implements PDWatch {
private HgPdWatchGrpc.HgPdWatchStub stub;
private final HgPdWatchGrpc.HgPdWatchStub stub;
private final String pdServerAddress;
private String pdServerAddress;
// TODO: support several servers.
PDWatchImpl(String pdServerAddress) {
this.pdServerAddress = pdServerAddress;
@ -55,7 +51,7 @@ final class PDWatchImpl implements PDWatch {
@Override
public boolean checkChannel() {
return stub != null && ! ((ManagedChannel) stub.getChannel()).isShutdown();
return stub != null && !((ManagedChannel) stub.getChannel()).isShutdown();
}
/**
@ -95,9 +91,9 @@ final class PDWatchImpl implements PDWatch {
private GraphWatcher(Listener listener) {
super(listener,
() -> WatchCreateRequest
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_GRAPH_CHANGE)
.build()
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_GRAPH_CHANGE)
.build()
);
}
@ -112,9 +108,9 @@ final class PDWatchImpl implements PDWatch {
private ShardGroupWatcher(Listener listener) {
super(listener,
() -> WatchCreateRequest
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_SHARD_GROUP_CHANGE)
.build()
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_SHARD_GROUP_CHANGE)
.build()
);
}
@ -129,9 +125,9 @@ final class PDWatchImpl implements PDWatch {
private PartitionWatcher(Listener listener) {
super(listener,
() -> WatchCreateRequest
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_PARTITION_CHANGE)
.build()
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_PARTITION_CHANGE)
.build()
);
}
@ -140,7 +136,7 @@ final class PDWatchImpl implements PDWatch {
WatchPartitionResponse res = watchResponse.getPartitionResponse();
PartitionEvent event = new PartitionEvent(res.getGraph(), res.getPartitionId(),
PartitionEvent.ChangeType.grpcTypeOf(
res.getChangeType()));
res.getChangeType()));
this.listener.onNext(event);
}
}
@ -149,9 +145,9 @@ final class PDWatchImpl implements PDWatch {
private NodeWatcher(Listener listener) {
super(listener,
() -> WatchCreateRequest
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_STORE_NODE_CHANGE)
.build()
.newBuilder()
.setWatchType(WatchType.WATCH_TYPE_STORE_NODE_CHANGE)
.build()
);
}
@ -179,7 +175,7 @@ final class PDWatchImpl implements PDWatch {
void init() {
this.reqStream = PDWatchImpl.this.stub.watch(this);
this.reqStream.onNext(WatchRequest.newBuilder().setCreateRequest(
this.requestSupplier.get()
this.requestSupplier.get()
).build());
}

View File

@ -17,9 +17,6 @@
package org.apache.hugegraph.pd.pulse;
/**
* @author lynn.bond@hotmail.com created on 2022/2/13
*/
public interface PulseServerNotice<T> {
/**
* @throws RuntimeException when failed to send ack-message to pd-server

View File

@ -17,9 +17,6 @@
package org.apache.hugegraph.pd.watch;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
public class PDWatcher {
}

View File

@ -21,9 +21,6 @@ import java.util.Objects;
import org.apache.hugegraph.pd.grpc.watch.WatchChangeType;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
public class PartitionEvent {
private final String graph;
private final int partitionId;

View File

@ -17,9 +17,6 @@
package org.apache.hugegraph.pd.watch;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
enum WatchType {
PARTITION_CHANGE(10);

View File

@ -27,9 +27,6 @@ import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
import org.apache.hugegraph.pd.grpc.discovery.Query;
import org.junit.Assert;
/**
* @date 2021/12/21
**/
public class DiscoveryClientImplTest {
private static final AtomicLong label = new AtomicLong();

View File

@ -30,9 +30,6 @@ import org.yaml.snakeyaml.Yaml;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2021/12/21
**/
@Slf4j
public class LicenseClientImplTest {
@ -49,7 +46,7 @@ public class LicenseClientImplTest {
log.info(error.getMessage());
assert error.getType().equals(Pdpb.ErrorType.OK);
} catch (Exception e) {
log.error("put license with error: {}", e);
log.error("put license with error: ", e);
}
}
@ -66,13 +63,13 @@ public class LicenseClientImplTest {
Object property = ymlConfig.get("rocksdb.write_buffer_size");
assert property.toString().equals("32000000");
} catch (Exception e) {
log.error("put license with error: {}", e);
log.error("put license with error: ", e);
}
}
// @Test
public void putKv() {
PDConfig pdConfig = PDConfig.of("10.14.139.70:8688");
PDConfig pdConfig = PDConfig.of("127.0.0.1.70:8688");
pdConfig.setEnableCache(true);
try (KvClient c = new KvClient(pdConfig)) {
long l = System.currentTimeMillis();
@ -81,7 +78,7 @@ public class LicenseClientImplTest {
log.info(error.getMessage());
assert error.getType().equals(Pdpb.ErrorType.OK);
} catch (Exception e) {
log.error("put license with error: {}", e);
log.error("put license with error: ", e);
}
}
@ -96,14 +93,14 @@ public class LicenseClientImplTest {
log.info(error.getMessage());
assert error.getType().equals(Pdpb.ErrorType.OK);
} catch (Exception e) {
log.error("put license with error: {}", e);
log.error("put license with error: ", e);
}
}
private Properties getYmlConfig(String yml) {
Yaml yaml = new Yaml();
Iterable load = yaml.loadAll(yml);
Iterator iterator = load.iterator();
Iterable<Object> load = yaml.loadAll(yml);
Iterator<Object> iterator = load.iterator();
Properties properties = new Properties();
while (iterator.hasNext()) {
Map<String, Object> next = (Map<String, Object>) iterator.next();
@ -127,4 +124,4 @@ public class LicenseClientImplTest {
}
}
}
}

View File

@ -25,9 +25,6 @@ import org.apache.hugegraph.pd.grpc.pulse.PartitionHeartbeatRequest;
import org.apache.hugegraph.pd.pulse.PulseServerNotice;
import org.junit.BeforeClass;
/**
* @author lynn.bond@hotmail.com created on 2021/11/8
*/
public class PDPulseTest {
private static PDClient pdClient;

View File

@ -22,9 +22,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.List;
/**
* @author lynn.bond@hotmail.com created on 2021/11/8
*/
public class HgPDTestUtil {
public static void println(Object str) {

View File

@ -20,9 +20,6 @@ package org.apache.hugegraph.pd.common;
import java.util.Collection;
import java.util.Map;
/**
* @author lynn.bond@hotmail.com
*/
public final class HgAssert {
public static void isTrue(boolean expression, String message) {

View File

@ -17,9 +17,6 @@
package org.apache.hugegraph.pd.common;
/**
* @date 2022/8/1
**/
public class PDRuntimeException extends RuntimeException {
// public static final int LICENSE_ERROR = -11;

View File

@ -31,9 +31,6 @@ import com.google.protobuf.GeneratedMessageV3;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2022/3/29
**/
@Slf4j
@Service
public class LogService {

View File

@ -25,9 +25,6 @@ import org.apache.hugegraph.pd.grpc.discovery.Query;
import org.apache.hugegraph.pd.meta.DiscoveryMetaStore;
import org.apache.hugegraph.pd.meta.MetadataFactory;
/**
* @date 2022/1/14
**/
public class RegistryService {
private final PDConfig pdConfig;
private final DiscoveryMetaStore meta;

View File

@ -35,9 +35,6 @@ import lombok.Data;
/**
* PD配置文件
*
* @author: yanjinbing
* @date: 2021/10/20
*/
@Data
@Component
@ -65,28 +62,14 @@ public class PDConfig {
private String licensePath;
@Autowired
private ThreadPoolGrpc threadPoolGrpc;
@Data
@Configuration
public class ThreadPoolGrpc {
@Value("${thread.pool.grpc.core:600}")
private int core;
@Value("${thread.pool.grpc.max:1000}")
private int max;
@Value("${thread.pool.grpc.queue:" + Integer.MAX_VALUE + "}")
private int queue;
}
@Autowired
private Raft raft;
@Autowired
private Store store;
@Autowired
private Partition partition;
@Autowired
private Discovery discovery;
private Map<String, String> initialStoreMap = null;
private ConfigService configService;
private IdService idService;
@ -128,6 +111,17 @@ public class PDConfig {
this.idService = idService;
}
@Data
@Configuration
public class ThreadPoolGrpc {
@Value("${thread.pool.grpc.core:600}")
private int core;
@Value("${thread.pool.grpc.max:1000}")
private int max;
@Value("${thread.pool.grpc.queue:" + Integer.MAX_VALUE + "}")
private int queue;
}
@Data
@Configuration
public class Raft {
@ -207,7 +201,7 @@ public class PDConfig {
private Long parseTimeExpression(String exp) {
if (exp != null) {
Pattern pattern = Pattern.compile(
"(?<n>(\\d+)*)(\\s)*(?<unit>(second|minute|hour|day|month|year)$)");
"(?<n>(\\d+)*)(\\s)*(?<unit>(second|minute|hour|day|month|year)$)");
Matcher matcher = pattern.matcher(exp.trim());
if (matcher.find()) {
String n = matcher.group("n");

View File

@ -30,9 +30,6 @@ import org.apache.hugegraph.pd.grpc.discovery.Query;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2022/1/14
**/
@Slf4j
public class DiscoveryMetaStore extends MetadataRocksDBStore {

View File

@ -23,9 +23,6 @@ import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.config.PDConfig;
import org.apache.hugegraph.pd.grpc.Metapb;
/**
* @date 2022/3/29
**/
public class LogMeta extends MetadataRocksDBStore {
private final PDConfig pdConfig;

View File

@ -30,9 +30,6 @@ import org.apache.hugegraph.pd.store.KV;
import com.google.protobuf.Parser;
/**
* @date 2022/1/9
**/
public class MetadataRocksDBStore extends MetadataStoreBase {
HgKVStore store;

View File

@ -26,9 +26,6 @@ import org.apache.hugegraph.pd.grpc.Metapb;
import org.apache.hugegraph.pd.raft.RaftEngine;
import org.apache.hugegraph.pd.store.RaftKVStore;
/**
* @author lynn.bond@hotmail.com on 2022/2/10
*/
public class QueueStore extends MetadataRocksDBStore {
QueueStore(PDConfig pdConfig) {
super(pdConfig);

View File

@ -24,9 +24,6 @@ import org.springframework.context.annotation.Configuration;
import io.micrometer.core.instrument.MeterRegistry;
/**
* @author lynn.bond@hotmail.com on 2022/01/05
*/
@Configuration
public class MetricsConfig {
@Autowired

View File

@ -31,9 +31,6 @@ import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/1/5
*/
@Component
@Slf4j
public final class PDMetrics {

View File

@ -19,9 +19,6 @@ package org.apache.hugegraph.pd.model;
import java.util.Objects;
/**
* @author lynn.bond@hotmail.com created on 2021/11/1
*/
public class DemoModel {
private int status;
private String text;

View File

@ -22,9 +22,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author lynn.bond@hotmail.com on 2022/2/14
*/
public class PromTargetsModel {
private static final String LABEL_METRICS_PATH = "__metrics_path__";
private static final String LABEL_SCHEME = "__scheme__";

View File

@ -21,9 +21,6 @@ import java.util.HashMap;
import lombok.Data;
/**
* @date 2022/2/8
**/
@Data
public class RegistryQueryRestRequest {

View File

@ -21,9 +21,6 @@ import java.util.HashMap;
import lombok.Data;
/**
* @date 2022/2/8
**/
@Data
public class RegistryRestRequest {

View File

@ -23,9 +23,6 @@ import org.apache.hugegraph.pd.grpc.Pdpb;
import lombok.Data;
/**
* @date 2022/2/8
**/
@Data
public class RegistryRestResponse {

View File

@ -23,10 +23,6 @@ import org.apache.hugegraph.pd.grpc.Pdpb;
import lombok.Data;
/**
* @author tianxiaohui
* @date 2022-07-21
*/
@Data
public class RestApiResponse {
String message;

View File

@ -19,9 +19,6 @@ package org.apache.hugegraph.pd.model;
import lombok.Data;
/**
* @date 2022/3/23
**/
@Data
public class TimeRangeRequest {
String startTime;

View File

@ -24,9 +24,6 @@ import org.apache.hugegraph.pd.common.HgAssert;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/2/10
*/
@Slf4j
public class NoticeBroadcaster {
private final Supplier<Long> noticeSupplier;

View File

@ -34,9 +34,6 @@ import io.grpc.Status;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/9
*/
@ThreadSafe
@Slf4j
abstract class AbstractObserverSubject {

View File

@ -57,24 +57,20 @@ import com.google.protobuf.Parser;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/8
* @version 1.1.0 added ack on 2020/02/11
*/
@Slf4j
@ThreadSafe
public class PDPulseSubject {
private final static long NOTICE_EXPIRATION_TIME = 30 * 60 * 1000;
private final static int RETRYING_PERIOD_SECONDS = 60;
private final static Map<String, AbstractObserverSubject> subjectHolder =
new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
private final static ConcurrentLinkedQueue<NoticeBroadcaster> broadcasterQueue =
new ConcurrentLinkedQueue<>();
new ConcurrentLinkedQueue<>();
private final static ScheduledExecutorService scheduledExecutor =
Executors.newScheduledThreadPool(1);
Executors.newScheduledThreadPool(1);
private static Supplier<List<Metapb.QueueItem>> queueRetrieveFunction =
() -> Collections.emptyList();
() -> Collections.emptyList();
private static Function<Metapb.QueueItem, Boolean> queueDurableFunction = (e) -> true;
private static Function<String, Boolean> queueRemoveFunction = (e) -> true;
@ -104,15 +100,15 @@ public class PDPulseSubject {
private static void appendQueue() {
broadcasterQueue.addAll(
getQueueItems()
.parallelStream()
.filter(e -> !broadcasterQueue
.stream()
.anyMatch(b -> e.getItemId().equals(b.getDurableId()))
).map(e -> createBroadcaster(e))
.peek(e -> log.info("Appending notice: {}", e))
.filter(e -> e != null)
.collect(Collectors.toList())
getQueueItems()
.parallelStream()
.filter(e -> !broadcasterQueue
.stream()
.anyMatch(b -> e.getItemId().equals(b.getDurableId()))
).map(e -> createBroadcaster(e))
.peek(e -> log.info("Appending notice: {}", e))
.filter(e -> e != null)
.collect(Collectors.toList())
);
}
@ -138,13 +134,13 @@ public class PDPulseSubject {
}
public static void setQueueRetrieveFunction(
Supplier<List<Metapb.QueueItem>> queueRetrieveFunction) {
Supplier<List<Metapb.QueueItem>> queueRetrieveFunction) {
HgAssert.isArgumentNotNull(queueRetrieveFunction, "queueRetrieveFunction");
PDPulseSubject.queueRetrieveFunction = queueRetrieveFunction;
}
public static void setQueueDurableFunction(
Function<Metapb.QueueItem, Boolean> queueDurableFunction) {
Function<Metapb.QueueItem, Boolean> queueDurableFunction) {
HgAssert.isArgumentNotNull(queueDurableFunction, "queueDurableFunction");
PDPulseSubject.queueDurableFunction = queueDurableFunction;
}
@ -161,7 +157,7 @@ public class PDPulseSubject {
* @return
*/
public static StreamObserver<PulseRequest> addObserver(
StreamObserver<PulseResponse> responseObserver) {
StreamObserver<PulseResponse> responseObserver) {
isArgumentNotNull(responseObserver, "responseObserver");
return new PDPulseStreamObserver(responseObserver);
}
@ -223,7 +219,7 @@ public class PDPulseSubject {
// }
public static <T extends com.google.protobuf.GeneratedMessageV3> Supplier<Long> getNoticeSupplier(
T notice) {
T notice) {
PulseType type;
if (notice instanceof PdInstructionResponse) {
type = PulseType.PULSE_TYPE_PD_INSTRUCTION;
@ -237,7 +233,7 @@ public class PDPulseSubject {
private static Supplier<String> getDurableSupplier(
com.google.protobuf.GeneratedMessageV3 notice) {
com.google.protobuf.GeneratedMessageV3 notice) {
return () -> {
Metapb.QueueItem queueItem = toQueueItem(notice);
String res = null;
@ -247,9 +243,9 @@ public class PDPulseSubject {
res = queueItem.getItemId();
} else {
log.error(
"Failed to persist queue-item that contained " +
"PartitionHeartbeatResponse: {}"
, notice);
"Failed to persist queue-item that contained " +
"PartitionHeartbeatResponse: {}"
, notice);
}
} catch (Throwable t) {
log.error("Failed to invoke queueDurableFunction, cause by:", t);
@ -333,7 +329,7 @@ public class PDPulseSubject {
if (this.subject == null) {
this.responseObserver.onError(
new Exception("Invoke cancel-observer before create-observer."));
new Exception("Invoke cancel-observer before create-observer."));
return;
}
@ -378,7 +374,7 @@ public class PDPulseSubject {
if (subject == null) {
responseObserver.onError(
new Exception("Unsupported pulse-type: " + pulseType.name()));
new Exception("Unsupported pulse-type: " + pulseType.name()));
return null;
}
@ -396,7 +392,7 @@ public class PDPulseSubject {
log.info("send change leader command to watch, due to ERROR-100", pde);
notifyClient(PdInstructionResponse.newBuilder()
.setInstructionType(
PdInstructionType.CHANGE_TO_FOLLOWER)
PdInstructionType.CHANGE_TO_FOLLOWER)
.setLeaderIp(RaftEngine.getInstance()
.getLeaderGrpcAddress())
.build());
@ -429,7 +425,7 @@ public class PDPulseSubject {
if (pulseRequest.hasAckRequest()) {
this.ackNotice(pulseRequest.getAckRequest().getNoticeId()
, pulseRequest.getAckRequest().getObserverId());
, pulseRequest.getAckRequest().getObserverId());
}
}

View File

@ -27,9 +27,6 @@ import org.apache.hugegraph.pd.grpc.pulse.PulseType;
import com.google.protobuf.GeneratedMessageV3;
/**
* @author lynn.bond@hotmail.com created on 2021/11/9
*/
public class PartitionHeartbeatSubject extends AbstractObserverSubject {
PartitionHeartbeatSubject() {

View File

@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/2/14
* TODO: ensure if we need this class & method (delete)
*/
@RestController
@Slf4j
@ -45,8 +45,9 @@ public class PromTargetsAPI {
private PromTargetsService service;
@GetMapping(value = "/targets/{appName}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<PromTargetsModel>> getPromTargets(
@PathVariable(value = "appName", required = true) String appName) {
public ResponseEntity<List<PromTargetsModel>> getPromTargets(@PathVariable(value = "appName",
required = true)
String appName) {
return ResponseEntity.of(Optional.ofNullable(this.service.getTargets(appName)));
}
@ -56,9 +57,9 @@ public class PromTargetsAPI {
}
@GetMapping(value = "/demo/targets/{appName}", produces = MediaType.APPLICATION_JSON_VALUE)
public List<PromTargetsModel> getDemoTargets(
@PathVariable(value = "appName", required = true) String targetType) {
public List<PromTargetsModel> getDemoTargets(@PathVariable(value = "appName",
required = true) String targetType) {
// TODO: ensure the IP addr is correct & useful
PromTargetsModel model = null;
switch (targetType) {
case "node":
@ -86,7 +87,6 @@ public class PromTargetsAPI {
default:
}
return Collections.singletonList(model);
}
}

View File

@ -50,9 +50,6 @@ import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
/**
* @date 2022/2/8
**/
@RestController
@Slf4j
@RequestMapping("/v1")

View File

@ -46,9 +46,6 @@ import com.google.protobuf.Parser;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/2/9
*/
@RestController
@Slf4j
@RequestMapping("/test")

View File

@ -37,16 +37,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
@Slf4j
@GRpcService
public class PDPulseService extends HgPdPulseGrpc.HgPdPulseImplBase {
private static final Supplier<List<Metapb.QueueItem>> QUEUE_RETRIEVE_FUNCTION =
() -> Collections.emptyList();
() -> Collections.emptyList();
private static final Function<Metapb.QueueItem, Boolean> QUEUE_ITEM_BOOLEAN_FUNCTION = (e) -> true;
private static final Function<String, Boolean> QUEUE_REMOVE_FUNCTION = (e) -> true;
@Autowired

View File

@ -26,9 +26,6 @@ import org.lognet.springboot.grpc.GRpcService;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
@Slf4j
@GRpcService
public class PDWatchService extends HgPdWatchGrpc.HgPdWatchImplBase {

View File

@ -44,9 +44,6 @@ import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/2/24
*/
@Service
@Slf4j
public class PromTargetsService {

View File

@ -30,9 +30,6 @@ import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.MethodDescriptor;
/**
* @date 2022/6/21
**/
public interface ServiceGrpc extends RaftStateListener {
ConcurrentHashMap<String, ManagedChannel> channels = new ConcurrentHashMap();

View File

@ -24,9 +24,6 @@ import org.apache.commons.lang3.time.DateUtils;
import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.grpc.Pdpb;
/**
* @date 2022/3/23
**/
public class DateUtil {
private static final String DATE = "yyyy-MM-dd";
private static final String DATETIME = "yyyy-MM-dd HH:mm:ss";

View File

@ -24,7 +24,6 @@ import java.util.function.Supplier;
/**
* @param <K>
* @param <V>
* @author lynn.bond@hotmail.com on 2022/3/10
*/
public class HgMapCache<K, V> {
private final Map<K, V> cache = new ConcurrentHashMap<K, V>();

View File

@ -19,9 +19,6 @@ package org.apache.hugegraph.pd.util;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com on 2022/2/8
*/
@Slf4j
public final class IdUtil {
private static final byte[] LOCK = new byte[0];

View File

@ -33,9 +33,6 @@ import io.grpc.Status;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/5
*/
@ThreadSafe
@Slf4j
abstract class AbstractWatchSubject {

View File

@ -42,8 +42,6 @@ import lombok.extern.slf4j.Slf4j;
/**
* watch订阅响应处理类
*
* @date 2022/6/21
**/
@Slf4j
public class KvWatchSubject {
@ -53,7 +51,7 @@ public class KvWatchSubject {
public static final String ALL_PREFIX = "W";
public static final long WATCH_TTL = 20000L;
private static final ConcurrentMap<String, StreamObserver<WatchResponse>> clients =
new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
private final KvService kvService;
BiPredicate<String, String> equal = String::equals;
BiPredicate<String, String> startWith = String::startsWith;
@ -76,7 +74,7 @@ public class KvWatchSubject {
String watchKey = KvService.getKeyWithoutPrefix(ALL_PREFIX, delimiter, key, clientId);
kvService.put(watchKey, "", WATCH_TTL);
String clientFirstKey =
KvService.getKeyWithoutPrefix(ALL_PREFIX, clientId, delimiter, key, clientId);
KvService.getKeyWithoutPrefix(ALL_PREFIX, clientId, delimiter, key, clientId);
kvService.put(clientFirstKey, "", WATCH_TTL);
}
@ -99,7 +97,7 @@ public class KvWatchSubject {
public void addObserver(String key, long clientId, StreamObserver<WatchResponse> observer,
String delimiter) throws PDException {
String keyWithoutPrefix =
KvService.getKeyWithoutPrefix(ALL_PREFIX, delimiter, key, clientId);
KvService.getKeyWithoutPrefix(ALL_PREFIX, delimiter, key, clientId);
clients.putIfAbsent(keyWithoutPrefix, observer);
addWatchKey(key, delimiter, clientId);
log.info("client:{},start to watch key:{}", clientId, key);
@ -108,7 +106,7 @@ public class KvWatchSubject {
public void removeObserver(String key, long clientId, String delimiter) throws PDException {
removeWatchKey(key, delimiter, clientId);
String keyWithoutPrefix =
KvService.getKeyWithoutPrefix(ALL_PREFIX, delimiter, key, clientId);
KvService.getKeyWithoutPrefix(ALL_PREFIX, delimiter, key, clientId);
clients.remove(keyWithoutPrefix);
}
@ -145,15 +143,15 @@ public class KvWatchSubject {
continue;
}
WatchKv watchKv =
WatchKv.newBuilder().setKey(kvKey).setValue(kv.getValue()).build();
WatchKv.newBuilder().setKey(kvKey).setValue(kv.getValue()).build();
WatchEvent event =
WatchEvent.newBuilder().setCurrent(watchKv).setType(watchType).build();
WatchEvent.newBuilder().setCurrent(watchKv).setType(watchType).build();
watchEvents.add(event);
}
StreamObserver<WatchResponse> observer = clients.get(keyAndClient);
watchResponse =
WatchResponse.newBuilder().setState(WatchState.Started).setClientId(clientId)
.addAllEvents(watchEvents).build();
WatchResponse.newBuilder().setState(WatchState.Started).setClientId(clientId)
.addAllEvents(watchEvents).build();
try {
if (observer != null) {
@ -188,7 +186,7 @@ public class KvWatchSubject {
WatchResponse testAlive = WatchResponse.newBuilder().setState(WatchState.Alive).build();
Set<Map.Entry<String, StreamObserver<WatchResponse>>> entries = clients.entrySet();
Map.Entry<String, StreamObserver<WatchResponse>>[] array =
entries.toArray(new Map.Entry[0]);
entries.toArray(new Map.Entry[0]);
Arrays.stream(array).parallel().forEach(entry -> {
StreamObserver<WatchResponse> value = entry.getValue();
String key = entry.getKey();
@ -262,7 +260,7 @@ public class KvWatchSubject {
*/
public void notifyClientChangeLeader() {
WatchResponse response =
WatchResponse.newBuilder().setState(WatchState.Leader_Changed).build();
WatchResponse.newBuilder().setState(WatchState.Leader_Changed).build();
for (Map.Entry<String, StreamObserver<WatchResponse>> entry : clients.entrySet()) {
StreamObserver<WatchResponse> value = entry.getValue();
String key = entry.getKey();
@ -287,4 +285,4 @@ public class KvWatchSubject {
}
}
}
}
}

View File

@ -27,8 +27,6 @@ import org.apache.hugegraph.pd.grpc.watch.WatchType;
/**
* The subject of partition change.
*
* @author lynn.bond@hotmail.com created on 2021/11/26
*/
@ThreadSafe
final class NodeChangeSubject extends AbstractWatchSubject {
@ -50,11 +48,11 @@ final class NodeChangeSubject extends AbstractWatchSubject {
super.notifyWatcher(builder -> {
builder.setNodeResponse(
builder.getNodeResponseBuilder().clear()
.setGraph(graph)
.setNodeId(nodeId)
.setNodeEventType(nodeEventType)
.build()
builder.getNodeResponseBuilder().clear()
.setGraph(graph)
.setNodeId(nodeId)
.setNodeEventType(nodeEventType)
.build()
);
});

View File

@ -35,9 +35,6 @@ import org.apache.hugegraph.pd.grpc.watch.WatchType;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
/**
* @author lynn.bond@hotmail.com created on 2021/11/4
*/
@Slf4j
@ThreadSafe
public class PDWatchSubject implements StreamObserver<WatchRequest> {

View File

@ -28,8 +28,6 @@ import org.apache.hugegraph.pd.grpc.watch.WatchType;
/**
* The subject of partition change.
*
* @author lynn.bond@hotmail.com created on 2021/11/5
*/
@ThreadSafe
final class PartitionChangeSubject extends AbstractWatchSubject {
@ -40,11 +38,10 @@ final class PartitionChangeSubject extends AbstractWatchSubject {
@Override
String toNoticeString(WatchResponse res) {
StringBuilder sb = new StringBuilder();
return sb.append("graph:").append(res.getPartitionResponse().getGraph())
.append(",")
.append("partitionId:").append(res.getPartitionResponse().getPartitionId())
.toString();
String sb = "graph:" + res.getPartitionResponse().getGraph() +
"," +
"partitionId:" + res.getPartitionResponse().getPartitionId();
return sb;
}
public void notifyWatcher(WatchChangeType changeType, String graph, int partitionId) {
@ -53,14 +50,14 @@ final class PartitionChangeSubject extends AbstractWatchSubject {
super.notifyWatcher(builder -> {
builder.setPartitionResponse(
builder.getPartitionResponseBuilder().clear()
.setGraph(graph)
.setPartitionId(partitionId)
.setChangeType(changeType)
.build()
builder.getPartitionResponseBuilder().clear()
.setGraph(graph)
.setPartitionId(partitionId)
.setChangeType(changeType)
.build()
);
});
}
}
}

View File

@ -24,9 +24,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.hugegraph.pd.boot.HugePDServer;
import org.springframework.boot.SpringApplication;
/**
* @date 2022/1/9
**/
public class PDServer0 {
static String SERVER_NAME = "server0";

View File

@ -24,9 +24,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.hugegraph.pd.boot.HugePDServer;
import org.springframework.boot.SpringApplication;
/**
* @date 2022/1/9
**/
public class PDServer1 {
static String SERVER_NAME = "server1";

View File

@ -24,9 +24,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.hugegraph.pd.boot.HugePDServer;
import org.springframework.boot.SpringApplication;
/**
* @date 2022/1/9
**/
public class PDServer2 {
static String SERVER_NAME = "server2";

View File

@ -24,9 +24,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.hugegraph.pd.boot.HugePDServer;
import org.springframework.boot.SpringApplication;
/**
* @date 2022/1/9
**/
public class PDServer3 {
static String SERVER_NAME = "server3";

View File

@ -28,10 +28,6 @@ import org.apache.hugegraph.pd.grpc.Pdpb;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author zhengfuquan
* @date 2022/11/28
**/
public class PDClientTest extends BaseClientTest {
@Test
public void testDbCompaction() {
@ -419,4 +415,4 @@ public class PDClientTest extends BaseClientTest {
e.printStackTrace();
}
}
}
}

View File

@ -27,10 +27,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
/**
* @author tianxiaohui
* @date 20221220
**/
public class RestApiTest extends BaseServerTest {
@Test
public void testQueryClusterInfo() throws URISyntaxException, IOException, InterruptedException,

View File

@ -65,7 +65,7 @@
<!-- 项目组自建仓库-->
<repository>
<id>star</id>
<url>http://10.14.139.8:8082/artifactory/star</url>
<url>http://127.0.0.1:8082/artifactory/star</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>