-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PURIFY] Revert "Move data stream transport and rest action to xpack …
…(#59593)" (#28) This commit reverts commit 2a89e13. Relicensing data streams from OSS to XPack. Signed-off-by: Peter Nied <[email protected]>
- Loading branch information
Showing
30 changed files
with
2,049 additions
and
121 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
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
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
148 changes: 148 additions & 0 deletions
148
...c/main/java/org/elasticsearch/action/admin/indices/datastream/CreateDataStreamAction.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,148 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch 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.elasticsearch.action.admin.indices.datastream; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.IndicesRequest; | ||
import org.elasticsearch.action.ValidateActions; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.IndicesOptions; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.action.support.master.TransportMasterNodeAction; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.block.ClusterBlockException; | ||
import org.elasticsearch.cluster.block.ClusterBlockLevel; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.metadata.MetadataCreateDataStreamService; | ||
import org.elasticsearch.cluster.metadata.MetadataCreateDataStreamService.CreateDataStreamClusterStateUpdateRequest; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class CreateDataStreamAction extends ActionType<AcknowledgedResponse> { | ||
|
||
public static final CreateDataStreamAction INSTANCE = new CreateDataStreamAction(); | ||
public static final String NAME = "indices:admin/data_stream/create"; | ||
|
||
private CreateDataStreamAction() { | ||
super(NAME, AcknowledgedResponse::new); | ||
} | ||
|
||
public static class Request extends AcknowledgedRequest<Request> implements IndicesRequest { | ||
|
||
private final String name; | ||
|
||
public Request(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (Strings.hasText(name) == false) { | ||
validationException = ValidateActions.addValidationError("name is missing", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
public Request(StreamInput in) throws IOException { | ||
super(in); | ||
this.name = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(name); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Request request = (Request) o; | ||
return name.equals(request.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name); | ||
} | ||
|
||
@Override | ||
public String[] indices() { | ||
return new String[]{name}; | ||
} | ||
|
||
@Override | ||
public IndicesOptions indicesOptions() { | ||
return IndicesOptions.strictSingleIndexNoExpandForbidClosed(); | ||
} | ||
} | ||
|
||
public static class TransportAction extends TransportMasterNodeAction<Request, AcknowledgedResponse> { | ||
|
||
private final MetadataCreateDataStreamService metadataCreateDataStreamService; | ||
|
||
@Inject | ||
public TransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, | ||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, | ||
MetadataCreateDataStreamService metadataCreateDataStreamService) { | ||
super(NAME, transportService, clusterService, threadPool, actionFilters, Request::new, indexNameExpressionResolver); | ||
this.metadataCreateDataStreamService = metadataCreateDataStreamService; | ||
} | ||
|
||
@Override | ||
protected String executor() { | ||
return ThreadPool.Names.SAME; | ||
} | ||
|
||
@Override | ||
protected AcknowledgedResponse read(StreamInput in) throws IOException { | ||
return new AcknowledgedResponse(in); | ||
} | ||
|
||
@Override | ||
protected void masterOperation(Request request, ClusterState state, | ||
ActionListener<AcknowledgedResponse> listener) throws Exception { | ||
CreateDataStreamClusterStateUpdateRequest updateRequest = new CreateDataStreamClusterStateUpdateRequest( | ||
request.name, | ||
request.masterNodeTimeout(), | ||
request.timeout() | ||
); | ||
metadataCreateDataStreamService.createDataStream(updateRequest, listener); | ||
} | ||
|
||
@Override | ||
protected ClusterBlockException checkBlock(Request request, ClusterState state) { | ||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.