Skip to content

Commit 8f93984

Browse files
committed
add process in CN: ExternalServiceInfo
Signed-off-by: Weihao Li <18110526956@163.com>
1 parent 86e3dfa commit 8f93984

26 files changed

Lines changed: 1434 additions & 2 deletions

File tree

iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ public enum TSStatusCode {
338338
RATIS_READ_UNAVAILABLE(2207),
339339
PIPE_CONSENSUS_CLOSE_ERROR(2208),
340340
PIPE_CONSENSUS_WAIT_ORDER_TIMEOUT(2209),
341+
342+
// ExternalService
343+
NO_SUCH_EXTERNAL_SERVICE(2300),
344+
EXTERNAL_SERVICE_ALREADY_ACTIVE(2301),
345+
EXTERNAL_SERVICE_ALREADY_EXIST(2302),
341346
;
342347

343348
private final int statusCode;

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import org.apache.iotdb.confignode.consensus.request.write.datanode.RegisterDataNodePlan;
4747
import org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan;
4848
import org.apache.iotdb.confignode.consensus.request.write.datanode.UpdateDataNodePlan;
49+
import org.apache.iotdb.confignode.consensus.request.write.externalservice.CreateExternalServicePlan;
50+
import org.apache.iotdb.confignode.consensus.request.write.externalservice.DropExternalServicePlan;
4951
import org.apache.iotdb.confignode.consensus.request.write.function.CreateFunctionPlan;
5052
import org.apache.iotdb.confignode.consensus.request.write.function.DropTableModelFunctionPlan;
5153
import org.apache.iotdb.confignode.consensus.request.write.function.DropTreeModelFunctionPlan;
@@ -588,6 +590,18 @@ public static ConfigPhysicalPlan create(final ByteBuffer buffer) throws IOExcept
588590
case setThrottleQuota:
589591
plan = new SetThrottleQuotaPlan();
590592
break;
593+
case CreateExternalService:
594+
plan = new CreateExternalServicePlan();
595+
break;
596+
case StartExternalService:
597+
plan = new StartExternalServicePlan();
598+
break;
599+
case StopExternalService:
600+
plan = new StopExternalServicePlan();
601+
break;
602+
case DropExternalService:
603+
plan = new DropExternalServicePlan();
604+
break;
591605
default:
592606
throw new IOException("unknown PhysicalPlan configPhysicalPlanType: " + planType);
593607
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ public enum ConfigPhysicalPlanType {
335335

336336
EnableSeparationOfAdminPowers((short) 2200),
337337

338+
CreateExternalService((short) 2301),
339+
StartExternalService((short) 2302),
340+
StopExternalService((short) 2303),
341+
DropExternalService((short) 2304),
342+
ShowExternalService((short) 2305),
343+
338344
/** Test Only. */
339345
TestOnly((short) 30000),
340346
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.consensus.request.read.exernalservice;
21+
22+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
23+
import org.apache.iotdb.confignode.consensus.request.read.ConfigPhysicalReadPlan;
24+
25+
import java.util.Objects;
26+
27+
/**
28+
* Get infos of ExternalService by the specific DataNode's id. And return all when dataNodeID is set
29+
* to -1.
30+
*/
31+
public class ShowExternalServicePlan extends ConfigPhysicalReadPlan {
32+
33+
private final int dataNodeId;
34+
35+
public ShowExternalServicePlan(final int dataNodeId) {
36+
super(ConfigPhysicalPlanType.GetDataNodeConfiguration);
37+
this.dataNodeId = dataNodeId;
38+
}
39+
40+
public Integer getDataNodeId() {
41+
return dataNodeId;
42+
}
43+
44+
@Override
45+
public boolean equals(final Object o) {
46+
if (this == o) {
47+
return true;
48+
}
49+
if (o == null || getClass() != o.getClass()) {
50+
return false;
51+
}
52+
final ShowExternalServicePlan that = (ShowExternalServicePlan) o;
53+
return dataNodeId == that.dataNodeId;
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return Objects.hash(dataNodeId);
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.consensus.request.write.externalservice;
21+
22+
import org.apache.iotdb.commons.externalservice.ServiceInfo;
23+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
24+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
25+
26+
import org.apache.tsfile.utils.ReadWriteIOUtils;
27+
28+
import java.io.DataOutputStream;
29+
import java.io.IOException;
30+
import java.nio.ByteBuffer;
31+
import java.util.Objects;
32+
33+
public class CreateExternalServicePlan extends ConfigPhysicalPlan {
34+
35+
private int datanodeId;
36+
private ServiceInfo serviceInfo;
37+
38+
public CreateExternalServicePlan() {
39+
super(ConfigPhysicalPlanType.CreateExternalService);
40+
}
41+
42+
public CreateExternalServicePlan(int datanodeId, ServiceInfo serviceInfo) {
43+
super(ConfigPhysicalPlanType.CreateExternalService);
44+
this.datanodeId = datanodeId;
45+
this.serviceInfo = serviceInfo;
46+
}
47+
48+
public int getDatanodeId() {
49+
return datanodeId;
50+
}
51+
52+
public ServiceInfo getServiceInfo() {
53+
return serviceInfo;
54+
}
55+
56+
@Override
57+
protected void serializeImpl(DataOutputStream stream) throws IOException {
58+
stream.writeShort(getType().getPlanType());
59+
60+
ReadWriteIOUtils.write(datanodeId, stream);
61+
serviceInfo.serialize(stream);
62+
}
63+
64+
@Override
65+
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
66+
datanodeId = ReadWriteIOUtils.readInt(buffer);
67+
serviceInfo = ServiceInfo.deserialize(buffer);
68+
}
69+
70+
@Override
71+
public boolean equals(Object o) {
72+
if (this == o) {
73+
return true;
74+
}
75+
if (o == null || getClass() != o.getClass()) {
76+
return false;
77+
}
78+
if (!super.equals(o)) {
79+
return false;
80+
}
81+
CreateExternalServicePlan that = (CreateExternalServicePlan) o;
82+
return datanodeId == that.datanodeId && Objects.equals(serviceInfo, that.serviceInfo);
83+
}
84+
85+
@Override
86+
public int hashCode() {
87+
return Objects.hash(super.hashCode(), datanodeId, serviceInfo);
88+
}
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.consensus.request.write.externalservice;
21+
22+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
23+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
24+
25+
import org.apache.tsfile.utils.ReadWriteIOUtils;
26+
27+
import java.io.DataOutputStream;
28+
import java.io.IOException;
29+
import java.nio.ByteBuffer;
30+
import java.util.Objects;
31+
32+
public class DropExternalServicePlan extends ConfigPhysicalPlan {
33+
34+
private int dataNodeId;
35+
private String serviceName;
36+
37+
public DropExternalServicePlan() {
38+
super(ConfigPhysicalPlanType.DropExternalService);
39+
}
40+
41+
public DropExternalServicePlan(int dataNodeId, String serviceName) {
42+
super(ConfigPhysicalPlanType.DropExternalService);
43+
this.dataNodeId = dataNodeId;
44+
this.serviceName = serviceName;
45+
}
46+
47+
public int getDataNodeId() {
48+
return dataNodeId;
49+
}
50+
51+
public String getServiceName() {
52+
return serviceName;
53+
}
54+
55+
@Override
56+
protected void serializeImpl(DataOutputStream stream) throws IOException {
57+
stream.writeShort(getType().getPlanType());
58+
ReadWriteIOUtils.write(dataNodeId, stream);
59+
ReadWriteIOUtils.write(serviceName, stream);
60+
}
61+
62+
@Override
63+
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
64+
dataNodeId = ReadWriteIOUtils.readInt(buffer);
65+
serviceName = ReadWriteIOUtils.readString(buffer);
66+
}
67+
68+
@Override
69+
public boolean equals(Object o) {
70+
if (this == o) {
71+
return true;
72+
}
73+
if (o == null || getClass() != o.getClass()) {
74+
return false;
75+
}
76+
if (!super.equals(o)) {
77+
return false;
78+
}
79+
DropExternalServicePlan that = (DropExternalServicePlan) o;
80+
return dataNodeId == that.dataNodeId && Objects.equals(serviceName, that.serviceName);
81+
}
82+
83+
@Override
84+
public int hashCode() {
85+
return Objects.hash(super.hashCode(), dataNodeId, serviceName);
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.consensus.request.write.externalservice;
21+
22+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
23+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
24+
25+
import org.apache.tsfile.utils.ReadWriteIOUtils;
26+
27+
import java.io.DataOutputStream;
28+
import java.io.IOException;
29+
import java.nio.ByteBuffer;
30+
import java.util.Objects;
31+
32+
public class StartExternalServicePlan extends ConfigPhysicalPlan {
33+
34+
private int dataNodeId;
35+
private String serviceName;
36+
37+
public StartExternalServicePlan() {
38+
super(ConfigPhysicalPlanType.StartExternalService);
39+
}
40+
41+
public StartExternalServicePlan(int dataNodeId, String serviceName) {
42+
super(ConfigPhysicalPlanType.StartExternalService);
43+
this.dataNodeId = dataNodeId;
44+
this.serviceName = serviceName;
45+
}
46+
47+
public int getDataNodeId() {
48+
return dataNodeId;
49+
}
50+
51+
public String getServiceName() {
52+
return serviceName;
53+
}
54+
55+
@Override
56+
protected void serializeImpl(DataOutputStream stream) throws IOException {
57+
stream.writeShort(getType().getPlanType());
58+
ReadWriteIOUtils.write(dataNodeId, stream);
59+
ReadWriteIOUtils.write(serviceName, stream);
60+
}
61+
62+
@Override
63+
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
64+
dataNodeId = ReadWriteIOUtils.readInt(buffer);
65+
serviceName = ReadWriteIOUtils.readString(buffer);
66+
}
67+
68+
@Override
69+
public boolean equals(Object o) {
70+
if (this == o) {
71+
return true;
72+
}
73+
if (o == null || getClass() != o.getClass()) {
74+
return false;
75+
}
76+
if (!super.equals(o)) {
77+
return false;
78+
}
79+
StartExternalServicePlan that = (StartExternalServicePlan) o;
80+
return dataNodeId == that.dataNodeId && Objects.equals(serviceName, that.serviceName);
81+
}
82+
83+
@Override
84+
public int hashCode() {
85+
return Objects.hash(super.hashCode(), dataNodeId, serviceName);
86+
}
87+
}

0 commit comments

Comments
 (0)