This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/develop by this push:
new 9899c25 [ISSUE #492] Support resources initilization and release of
connector in EventMesh (#493)
9899c25 is described below
commit 9899c2503539ebdc6dadfb2dfca4a703dadaf60d
Author: lrhkobe <[email protected]>
AuthorDate: Fri Aug 13 15:01:04 2021 +0800
[ISSUE #492] Support resources initilization and release of connector in
EventMesh (#493)
* modify:optimize flow control in downstreaming msg
* modify:optimize stategy of selecting session in downstream msg
* modify:optimize msg downstream,msg store in session
* modify:fix bug:not a @Sharable handler
* modify:downstream broadcast msg asynchronously
* modify:remove unneccessary interface in eventmesh-connector-api
* modify:fix conflict
* modify:add license in EventMeshAction
* modify:fix ack problem
* modify:fix exception handle when exception occured in
EventMeshTcpMessageDispatcher
* modify:fix log print
* modify:support connector resource init and release in eventmesh
* modify: fix security plugin load problem
close #492
---
.../api/connector/ConnectorResourceService.java | 37 +++++++++++++++++++
.../ConnectorResourceServiceRocketmqImpl.java | 31 ++++++++++++++++
...ventmesh.api.connector.ConnectorResourceService | 2 +-
.../eventmesh/runtime/boot/EventMeshServer.java | 8 +++++
.../runtime/connector/ConnectorResource.java | 41 ++++++++++++++++++++++
.../org.apache.eventmesh.api.acl.AclService | 2 +-
6 files changed, 119 insertions(+), 2 deletions(-)
diff --git
a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/connector/ConnectorResourceService.java
b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/connector/ConnectorResourceService.java
new file mode 100644
index 0000000..d48f8ce
--- /dev/null
+++
b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/connector/ConnectorResourceService.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding 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.eventmesh.api.connector;
+
+import org.apache.eventmesh.spi.EventMeshSPI;
+
+@EventMeshSPI(isSingleton = true)
+public interface ConnectorResourceService {
+
+ /**
+ * Resource initialization in connector,such as,some public threadpool if
exist
+ *
+ * @throws Exception
+ */
+ void init() throws Exception;
+
+ /**
+ *Resource release in connector,such as,some public threadpool if exist
+ *
+ * @throws Exception
+ */
+ void release() throws Exception;
+}
diff --git
a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/connector/ConnectorResourceServiceRocketmqImpl.java
b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/connector/ConnectorResourceServiceRocketmqImpl.java
new file mode 100644
index 0000000..f802ec0
--- /dev/null
+++
b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/connector/ConnectorResourceServiceRocketmqImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding 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.eventmesh.connector.rocketmq.connector;
+
+import org.apache.eventmesh.api.connector.ConnectorResourceService;
+
+public class ConnectorResourceServiceRocketmqImpl implements
ConnectorResourceService {
+ @Override
+ public void init() throws Exception {
+
+ }
+
+ @Override
+ public void release() throws Exception {
+
+ }
+}
diff --git
a/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.connector.ConnectorResourceService
similarity index 89%
copy from
eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
copy to
eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.connector.ConnectorResourceService
index b883bd8..fadf0de 100644
---
a/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
+++
b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.connector.ConnectorResourceService
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-acl=org.apache.eventmesh.acl.impl.AclServiceImpl
\ No newline at end of file
+rocketmq=org.apache.eventmesh.connector.rocketmq.connector.ConnectorResourceServiceRocketmqImpl
\ No newline at end of file
diff --git
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java
index 615731d..39c2a0c 100644
---
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java
+++
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshServer.java
@@ -21,6 +21,7 @@ import org.apache.eventmesh.runtime.acl.Acl;
import org.apache.eventmesh.runtime.common.ServiceState;
import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration;
import org.apache.eventmesh.runtime.configuration.EventMeshTCPConfiguration;
+import org.apache.eventmesh.runtime.connector.ConnectorResource;
import org.apache.eventmesh.runtime.constants.EventMeshConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +40,8 @@ public class EventMeshServer {
private Acl acl;
+ private ConnectorResource connectorResource;
+
private ServiceState serviceState;
public EventMeshServer(EventMeshHTTPConfiguration
eventMeshHttpConfiguration,
@@ -46,6 +49,7 @@ public class EventMeshServer {
this.eventMeshHttpConfiguration = eventMeshHttpConfiguration;
this.eventMeshTCPConfiguration = eventMeshTCPConfiguration;
this.acl = new Acl();
+ this.connectorResource = new ConnectorResource();
}
public void init() throws Exception {
@@ -53,6 +57,8 @@ public class EventMeshServer {
acl.init(eventMeshHttpConfiguration.eventMeshSecurityPluginType);
}
+
connectorResource.init(eventMeshHttpConfiguration.eventMeshConnectorPluginType);
+
eventMeshHTTPServer = new EventMeshHTTPServer(this,
eventMeshHttpConfiguration);
eventMeshHTTPServer.init();
eventMeshTCPServer = new EventMeshTCPServer(this,
eventMeshTCPConfiguration);
@@ -88,6 +94,8 @@ public class EventMeshServer {
eventMeshTCPServer.shutdown();
}
+ connectorResource.release();
+
if(eventMeshHttpConfiguration != null &&
eventMeshHttpConfiguration.eventMeshServerSecurityEnable){
acl.shutdown();
}
diff --git
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/connector/ConnectorResource.java
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/connector/ConnectorResource.java
new file mode 100644
index 0000000..38cf8e9
--- /dev/null
+++
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/connector/ConnectorResource.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding 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.eventmesh.runtime.connector;
+
+import org.apache.eventmesh.api.connector.ConnectorResourceService;
+import org.apache.eventmesh.spi.EventMeshExtensionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConnectorResource {
+
+ private static final Logger logger =
LoggerFactory.getLogger(ConnectorResource.class);
+ private static ConnectorResourceService connectorResourceService;
+
+ public void init(String connectorResourcePluginType) throws Exception{
+ connectorResourceService =
EventMeshExtensionFactory.getExtension(ConnectorResourceService.class,
connectorResourcePluginType);
+ if (connectorResourceService == null) {
+ logger.error("can't load the connectorResourceService plugin,
please check.");
+ throw new RuntimeException("doesn't load the
connectorResourceService plugin, please check.");
+ }
+ connectorResourceService.init();
+ }
+
+ public void release()throws Exception{
+ connectorResourceService.release();
+ }
+}
diff --git
a/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
b/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
index b883bd8..3225b6c 100644
---
a/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
+++
b/eventmesh-security-plugin/eventmesh-security-acl/src/main/resources/META-INF/eventmesh/org.apache.eventmesh.api.acl.AclService
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-acl=org.apache.eventmesh.acl.impl.AclServiceImpl
\ No newline at end of file
+security=org.apache.eventmesh.acl.impl.AclServiceImpl
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]