() {
+ public Direction findValueByNumber(int number) {
+ return Direction.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ if (this == UNRECOGNIZED) {
+ throw new IllegalStateException(
+ "Can't get the descriptor of an unrecognized enum value.");
+ }
+ return getDescriptor().getValues().get(ordinal());
+ }
+
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return ClusterMsg.getDescriptor().getEnumTypes().get(1);
+ }
+
+ private static final Direction[] VALUES = values();
+
+ public static Direction valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ if (desc.getIndex() == -1) {
+ return UNRECOGNIZED;
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private Direction(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:org.dromara.hertzbeat.common.entity.message.Direction)
+ }
+
public interface MessageOrBuilder extends
// @@protoc_insertion_point(interface_extends:org.dromara.hertzbeat.common.entity.message.Message)
com.google.protobuf.MessageOrBuilder {
@@ -283,12 +431,34 @@ public interface MessageOrBuilder extends
com.google.protobuf.ByteString
getIdentityBytes();
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The enum numeric value on the wire for direction.
+ */
+ int getDirectionValue();
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The direction.
+ */
+ Direction getDirection();
+
/**
*
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The enum numeric value on the wire for type.
*/
@@ -299,7 +469,7 @@ public interface MessageOrBuilder extends
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The type.
*/
@@ -310,7 +480,7 @@ public interface MessageOrBuilder extends
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The msg.
*/
@@ -321,7 +491,7 @@ public interface MessageOrBuilder extends
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The bytes for msg.
*/
@@ -345,6 +515,7 @@ private Message(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
private Message() {
identity_ = "";
+ direction_ = 0;
type_ = 0;
msg_ = "";
}
@@ -389,10 +560,16 @@ private Message(
case 16: {
int rawValue = input.readEnum();
+ direction_ = rawValue;
+ break;
+ }
+ case 24: {
+ int rawValue = input.readEnum();
+
type_ = rawValue;
break;
}
- case 26: {
+ case 34: {
String s = input.readStringRequireUtf8();
msg_ = s;
@@ -483,7 +660,40 @@ public String getIdentity() {
}
}
- public static final int TYPE_FIELD_NUMBER = 2;
+ public static final int DIRECTION_FIELD_NUMBER = 2;
+ private int direction_;
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The enum numeric value on the wire for direction.
+ */
+ @Override
+ public int getDirectionValue() {
+ return direction_;
+ }
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The direction.
+ */
+ @Override
+ public Direction getDirection() {
+ @SuppressWarnings("deprecation")
+ Direction result = Direction.valueOf(direction_);
+ return result == null ? Direction.UNRECOGNIZED : result;
+ }
+
+ public static final int TYPE_FIELD_NUMBER = 3;
private int type_;
/**
@@ -491,7 +701,7 @@ public String getIdentity() {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The enum numeric value on the wire for type.
*/
@@ -505,7 +715,7 @@ public int getTypeValue() {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The type.
*/
@@ -516,7 +726,7 @@ public MessageType getType() {
return result == null ? MessageType.UNRECOGNIZED : result;
}
- public static final int MSG_FIELD_NUMBER = 3;
+ public static final int MSG_FIELD_NUMBER = 4;
private volatile Object msg_;
/**
@@ -524,7 +734,7 @@ public MessageType getType() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The msg.
*/
@@ -547,7 +757,7 @@ public String getMsg() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The bytes for msg.
*/
@@ -584,11 +794,14 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(identity_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, identity_);
}
+ if (direction_ != Direction.REQUEST.getNumber()) {
+ output.writeEnum(2, direction_);
+ }
if (type_ != MessageType.HEARTBEAT.getNumber()) {
- output.writeEnum(2, type_);
+ output.writeEnum(3, type_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(msg_)) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 3, msg_);
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, msg_);
}
unknownFields.writeTo(output);
}
@@ -602,12 +815,16 @@ public int getSerializedSize() {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(identity_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, identity_);
}
+ if (direction_ != Direction.REQUEST.getNumber()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(2, direction_);
+ }
if (type_ != MessageType.HEARTBEAT.getNumber()) {
size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(2, type_);
+ .computeEnumSize(3, type_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(msg_)) {
- size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, msg_);
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, msg_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
@@ -626,6 +843,7 @@ public boolean equals(final Object obj) {
if (!getIdentity()
.equals(other.getIdentity())) return false;
+ if (direction_ != other.direction_) return false;
if (type_ != other.type_) return false;
if (!getMsg()
.equals(other.getMsg())) return false;
@@ -642,6 +860,8 @@ public int hashCode() {
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + IDENTITY_FIELD_NUMBER;
hash = (53 * hash) + getIdentity().hashCode();
+ hash = (37 * hash) + DIRECTION_FIELD_NUMBER;
+ hash = (53 * hash) + direction_;
hash = (37 * hash) + TYPE_FIELD_NUMBER;
hash = (53 * hash) + type_;
hash = (37 * hash) + MSG_FIELD_NUMBER;
@@ -800,6 +1020,8 @@ public Builder clear() {
super.clear();
identity_ = "";
+ direction_ = 0;
+
type_ = 0;
msg_ = "";
@@ -831,6 +1053,7 @@ public Message build() {
public Message buildPartial() {
Message result = new Message(this);
result.identity_ = identity_;
+ result.direction_ = direction_;
result.type_ = type_;
result.msg_ = msg_;
onBuilt();
@@ -891,6 +1114,9 @@ public Builder mergeFrom(Message other) {
identity_ = other.identity_;
onChanged();
}
+ if (other.direction_ != 0) {
+ setDirectionValue(other.getDirectionValue());
+ }
if (other.type_ != 0) {
setTypeValue(other.getTypeValue());
}
@@ -1033,6 +1259,91 @@ public Builder setIdentityBytes(
return this;
}
+ private int direction_ = 0;
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The enum numeric value on the wire for direction.
+ */
+ @Override
+ public int getDirectionValue() {
+ return direction_;
+ }
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @param value The enum numeric value on the wire for direction to set.
+ * @return This builder for chaining.
+ */
+ public Builder setDirectionValue(int value) {
+
+ direction_ = value;
+ onChanged();
+ return this;
+ }
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return The direction.
+ */
+ @Override
+ public Direction getDirection() {
+ @SuppressWarnings("deprecation")
+ Direction result = Direction.valueOf(direction_);
+ return result == null ? Direction.UNRECOGNIZED : result;
+ }
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @param value The direction to set.
+ * @return This builder for chaining.
+ */
+ public Builder setDirection(Direction value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ direction_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+
+ /**
+ *
+ * message direction
+ *
+ *
+ * .org.dromara.hertzbeat.common.entity.message.Direction direction = 2;
+ *
+ * @return This builder for chaining.
+ */
+ public Builder clearDirection() {
+
+ direction_ = 0;
+ onChanged();
+ return this;
+ }
+
private int type_ = 0;
/**
@@ -1040,7 +1351,7 @@ public Builder setIdentityBytes(
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The enum numeric value on the wire for type.
*/
@@ -1054,7 +1365,7 @@ public int getTypeValue() {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @param value The enum numeric value on the wire for type to set.
* @return This builder for chaining.
@@ -1071,7 +1382,7 @@ public Builder setTypeValue(int value) {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return The type.
*/
@@ -1087,7 +1398,7 @@ public MessageType getType() {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @param value The type to set.
* @return This builder for chaining.
@@ -1107,7 +1418,7 @@ public Builder setType(MessageType value) {
* message type
*
*
- * .org.dromara.hertzbeat.common.entity.message.MessageType type = 2;
+ * .org.dromara.hertzbeat.common.entity.message.MessageType type = 3;
*
* @return This builder for chaining.
*/
@@ -1125,7 +1436,7 @@ public Builder clearType() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The msg.
*/
@@ -1147,7 +1458,7 @@ public String getMsg() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return The bytes for msg.
*/
@@ -1170,7 +1481,7 @@ public String getMsg() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @param value The msg to set.
* @return This builder for chaining.
@@ -1191,7 +1502,7 @@ public Builder setMsg(
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @return This builder for chaining.
*/
@@ -1207,7 +1518,7 @@ public Builder clearMsg() {
* message content
*
*
- * string msg = 3;
+ * string msg = 4;
*
* @param value The bytes for msg to set.
* @return This builder for chaining.
@@ -1295,15 +1606,18 @@ public Message getDefaultInstanceForType() {
static {
String[] descriptorData = {
"\n\021cluster_msg.proto\022+org.dromara.hertzbe" +
- "at.common.entity.message\"p\n\007Message\022\020\n\010i" +
- "dentity\030\001 \001(\t\022F\n\004type\030\002 \001(\01628.org.dromar" +
- "a.hertzbeat.common.entity.message.Messag" +
- "eType\022\013\n\003msg\030\003 \001(\t*\303\001\n\013MessageType\022\r\n\tHE" +
- "ARTBEAT\020\000\022\r\n\tGO_ONLINE\020\001\022\016\n\nGO_OFFLINE\020\002" +
- "\022\025\n\021ISSUE_CYCLIC_TASK\020\003\022\026\n\022DELETE_CYCLIC" +
- "_TASK\020\004\022\027\n\023ISSUE_ONE_TIME_TASK\020\005\022\037\n\033RESP" +
- "ONSE_ONE_TIME_TASK_DATA\020\006\022\035\n\031RESPONSE_CY" +
- "CLIC_TASK_DATA\020\007b\006proto3"
+ "at.common.entity.message\"\273\001\n\007Message\022\020\n\010" +
+ "identity\030\001 \001(\t\022I\n\tdirection\030\002 \001(\01626.org." +
+ "dromara.hertzbeat.common.entity.message." +
+ "Direction\022F\n\004type\030\003 \001(\01628.org.dromara.he" +
+ "rtzbeat.common.entity.message.MessageTyp" +
+ "e\022\013\n\003msg\030\004 \001(\t*\321\001\n\013MessageType\022\r\n\tHEARTB" +
+ "EAT\020\000\022\r\n\tGO_ONLINE\020\001\022\016\n\nGO_OFFLINE\020\002\022\025\n\021" +
+ "ISSUE_CYCLIC_TASK\020\003\022\026\n\022DELETE_CYCLIC_TAS" +
+ "K\020\004\022\027\n\023ISSUE_ONE_TIME_TASK\020\005\022\037\n\033RESPONSE" +
+ "_ONE_TIME_TASK_DATA\020\006\022\035\n\031RESPONSE_CYCLIC" +
+ "_TASK_DATA\020\007\022\014\n\010GO_CLOSE\020\010*&\n\tDirection\022" +
+ "\013\n\007REQUEST\020\000\022\014\n\010RESPONSE\020\001b\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@@ -1314,7 +1628,7 @@ public Message getDefaultInstanceForType() {
internal_static_org_dromara_hertzbeat_common_entity_message_Message_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_org_dromara_hertzbeat_common_entity_message_Message_descriptor,
- new String[]{"Identity", "Type", "Msg",});
+ new String[]{"Identity", "Direction", "Type", "Msg",});
}
// @@protoc_insertion_point(outer_class_scope)
diff --git a/common/src/main/java/org/dromara/hertzbeat/common/support/SpringContextHolder.java b/common/src/main/java/org/dromara/hertzbeat/common/support/SpringContextHolder.java
index dbecae8146d..22dacc3baba 100644
--- a/common/src/main/java/org/dromara/hertzbeat/common/support/SpringContextHolder.java
+++ b/common/src/main/java/org/dromara/hertzbeat/common/support/SpringContextHolder.java
@@ -20,6 +20,7 @@
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
/**
@@ -31,10 +32,15 @@
public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
+
+ private static ConfigurableApplicationContext configurableApplicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
set(applicationContext);
+ if (applicationContext instanceof ConfigurableApplicationContext) {
+ configurableApplicationContext = (ConfigurableApplicationContext) applicationContext;
+ }
}
private static void set(ApplicationContext applicationContext) {
@@ -56,10 +62,22 @@ public static T getBean(Class tClass) {
assertApplicationContext();
return (T) applicationContext.getBean(tClass);
}
+
+ public static void shutdown() {
+ assertApplicationContext();
+ configurableApplicationContext.close();
+ }
+
+ public static boolean isActive() {
+ if (configurableApplicationContext == null) {
+ return false;
+ }
+ return configurableApplicationContext.isActive();
+ }
private static void assertApplicationContext() {
- if (null == SpringContextHolder.applicationContext) {
- throw new RuntimeException("applicationContext为空,请检查是否注入springContextHolder");
+ if (null == applicationContext || null == configurableApplicationContext) {
+ throw new RuntimeException("applicationContext is null, please inject the springContextHolder");
}
}
}
diff --git a/common/src/main/message/cluster_msg.proto b/common/src/main/message/cluster_msg.proto
index fd1e291ee12..af200b033b0 100644
--- a/common/src/main/message/cluster_msg.proto
+++ b/common/src/main/message/cluster_msg.proto
@@ -22,10 +22,12 @@ message Message
{
// collector identity
string identity = 1;
+ // message direction
+ Direction direction = 2;
// message type
- MessageType type = 2;
+ MessageType type = 3;
// message content
- string msg = 3;
+ string msg = 4;
}
enum MessageType
@@ -46,4 +48,13 @@ enum MessageType
RESPONSE_ONE_TIME_TASK_DATA = 6;
// response cyclic collect data
RESPONSE_CYCLIC_TASK_DATA = 7;
+ // collector go close to master
+ GO_CLOSE = 8;
+}
+
+enum Direction {
+ // request message
+ REQUEST = 0;
+ // request response
+ RESPONSE = 1;
}
diff --git a/manager/pom.xml b/manager/pom.xml
index cfcfb736ae7..bf0a6be8840 100644
--- a/manager/pom.xml
+++ b/manager/pom.xml
@@ -60,6 +60,11 @@
org.dromara.hertzbeat
hertzbeat-collector