forked from alibaba/havenask-federation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fed分布式适配kill havenask searcher的rest接口 (alibaba#431)
现在可以通过设置node参数指定由哪个node进行kill searcher的操作,未指定时,所有节点都执行kill searcher的操作。 e.g. #所有节点都执行kill searcher操作 POST /_havenask/stop?role=searcher #node1 执行kill searcher操作 POST /_havenask/stop?role=searcher&node=node1 #node1、node2 与node3 执行kill searcher操作 POST /_havenask/stop?role=searcher&node=node1,node2,node3
- Loading branch information
Showing
8 changed files
with
271 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...avenask-engine/src/main/java/org/havenask/engine/stop/action/HavenaskStopNodeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2021, Alibaba Group; | ||
* Licensed 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.havenask.engine.stop.action; | ||
|
||
import org.havenask.action.support.nodes.BaseNodeRequest; | ||
import org.havenask.common.io.stream.StreamInput; | ||
import org.havenask.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class HavenaskStopNodeRequest extends BaseNodeRequest { | ||
HavenaskStopRequest request; | ||
|
||
public HavenaskStopNodeRequest(StreamInput in) throws IOException { | ||
super(in); | ||
request = new HavenaskStopRequest(in); | ||
} | ||
|
||
public HavenaskStopNodeRequest(HavenaskStopRequest havenaskStopRequest) { | ||
this.request = havenaskStopRequest; | ||
} | ||
|
||
public String getRole() { | ||
return request.getRole(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
request.writeTo(out); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...venask-engine/src/main/java/org/havenask/engine/stop/action/HavenaskStopNodeResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) 2021, Alibaba Group; | ||
* Licensed 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.havenask.engine.stop.action; | ||
|
||
import org.havenask.action.support.nodes.BaseNodeResponse; | ||
import org.havenask.cluster.node.DiscoveryNode; | ||
import org.havenask.common.io.stream.StreamInput; | ||
import org.havenask.common.io.stream.StreamOutput; | ||
import org.havenask.common.xcontent.ToXContent; | ||
import org.havenask.common.xcontent.ToXContentObject; | ||
import org.havenask.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
public class HavenaskStopNodeResponse extends BaseNodeResponse implements ToXContentObject { | ||
private final String nodeName; | ||
private final String result; | ||
private final int resultCode; | ||
|
||
public HavenaskStopNodeResponse(StreamInput in) throws IOException { | ||
super(in); | ||
result = in.readString(); | ||
resultCode = in.readInt(); | ||
nodeName = getNode().getName(); | ||
} | ||
|
||
public HavenaskStopNodeResponse(DiscoveryNode node, String result, int resultCode) { | ||
super(node); | ||
this.result = result; | ||
this.resultCode = resultCode; | ||
this.nodeName = node.getName(); | ||
} | ||
|
||
public String getResult() { | ||
return result; | ||
} | ||
|
||
public int getResultCode() { | ||
return resultCode; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(result); | ||
out.writeInt(resultCode); | ||
} | ||
|
||
public static HavenaskStopNodeResponse readNodeResponse(StreamInput in) throws IOException { | ||
return new HavenaskStopNodeResponse(in); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
// String to XContentBuilder | ||
builder.startObject(); | ||
builder.field("result", result); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return " { \n" | ||
+ " nodeName: " | ||
+ nodeName | ||
+ ";\n" | ||
+ " result: " | ||
+ result | ||
+ "\n" | ||
+ " resultCode: " | ||
+ resultCode | ||
+ "\n" | ||
+ " }"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.