forked from elastic/elasticsearch
-
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.
- Loading branch information
1 parent
baad90c
commit 61817f5
Showing
10 changed files
with
223 additions
and
6 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
24 changes: 24 additions & 0 deletions
24
server/src/main/java/org/elasticsearch/action/bulk/ShardMarkCommitAndIndexAction.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,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.bulk; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class ShardMarkCommitAndIndexAction extends ActionType<ShardMarkCommitAndIndexResponse> { | ||
|
||
public static final ShardMarkCommitAndIndexAction INSTANCE = new ShardMarkCommitAndIndexAction(); | ||
// todo: should the name be bulk[prepare] style? | ||
public static final String NAME = "indices:data/write/commit"; | ||
|
||
private ShardMarkCommitAndIndexAction() { | ||
super(NAME, ShardMarkCommitAndIndexResponse::new); | ||
} | ||
|
||
// todo: transport options? | ||
} |
46 changes: 46 additions & 0 deletions
46
server/src/main/java/org/elasticsearch/action/bulk/ShardMarkCommitAndIndexRequest.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,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.bulk; | ||
|
||
import org.elasticsearch.action.support.replication.ReplicatedWriteRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.index.shard.ShardId; | ||
|
||
import java.io.IOException; | ||
|
||
// todo: make this a per node request. | ||
public class ShardMarkCommitAndIndexRequest extends ReplicatedWriteRequest<ShardMarkCommitAndIndexRequest> { | ||
private final TxID txID; | ||
|
||
public ShardMarkCommitAndIndexRequest(ShardId shardId, TxID txID) { | ||
super(shardId); | ||
this.txID = txID; | ||
} | ||
|
||
public ShardMarkCommitAndIndexRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.txID = new TxID(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
txID.writeTo(out); | ||
} | ||
|
||
public TxID txid() { | ||
return txID; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[" + shardId + "," + txID + "]"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
server/src/main/java/org/elasticsearch/action/bulk/ShardMarkCommitAndIndexResponse.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,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.bulk; | ||
|
||
import org.elasticsearch.action.support.WriteResponse; | ||
import org.elasticsearch.action.support.replication.ReplicationResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class ShardMarkCommitAndIndexResponse extends ReplicationResponse implements WriteResponse { | ||
|
||
|
||
public ShardMarkCommitAndIndexResponse() { | ||
} | ||
|
||
public ShardMarkCommitAndIndexResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
|
||
@Override | ||
public void setForcedRefresh(boolean forcedRefresh) { | ||
// this does not refresh currently. | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
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
92 changes: 92 additions & 0 deletions
92
...r/src/main/java/org/elasticsearch/action/bulk/TransportShardMarkCommitAndIndexAction.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,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.bulk; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.replication.TransportWriteAction; | ||
import org.elasticsearch.cluster.action.shard.ShardStateAction; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.index.IndexingPressure; | ||
import org.elasticsearch.index.shard.IndexShard; | ||
import org.elasticsearch.indices.ExecutorSelector; | ||
import org.elasticsearch.indices.IndicesService; | ||
import org.elasticsearch.indices.SystemIndices; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
|
||
public class TransportShardMarkCommitAndIndexAction extends TransportWriteAction< | ||
ShardMarkCommitAndIndexRequest, | ||
ShardMarkCommitAndIndexRequest, | ||
ShardMarkCommitAndIndexResponse> { | ||
|
||
@Inject | ||
public TransportShardMarkCommitAndIndexAction( | ||
Settings settings, | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
IndicesService indicesService, | ||
ThreadPool threadPool, | ||
ShardStateAction shardStateAction, | ||
ActionFilters actionFilters, | ||
IndexingPressure indexingPressure, | ||
SystemIndices systemIndices | ||
) { | ||
super( | ||
settings, | ||
ShardMarkCommitAndIndexAction.NAME, | ||
transportService, | ||
clusterService, | ||
indicesService, | ||
threadPool, | ||
shardStateAction, | ||
actionFilters, | ||
ShardMarkCommitAndIndexRequest::new, | ||
ShardMarkCommitAndIndexRequest::new, | ||
ExecutorSelector::getWriteExecutorForShard, | ||
false, | ||
indexingPressure, | ||
systemIndices | ||
); | ||
} | ||
|
||
@Override | ||
protected ShardMarkCommitAndIndexResponse newResponseInstance(StreamInput in) throws IOException { | ||
return new ShardMarkCommitAndIndexResponse(in); | ||
} | ||
|
||
@Override | ||
protected void dispatchedShardOperationOnPrimary( | ||
ShardMarkCommitAndIndexRequest request, | ||
IndexShard primary, | ||
ActionListener<PrimaryResult<ShardMarkCommitAndIndexRequest, ShardMarkCommitAndIndexResponse>> listener | ||
) { | ||
ActionListener.completeWith(listener, () -> { | ||
primary.commitTransaction(request.txid()); | ||
return new PrimaryResult<>(request, new ShardMarkCommitAndIndexResponse()); | ||
}); | ||
} | ||
|
||
@Override | ||
protected void dispatchedShardOperationOnReplica( | ||
ShardMarkCommitAndIndexRequest request, | ||
IndexShard replica, | ||
ActionListener<ReplicaResult> listener | ||
) { | ||
ActionListener.completeWith(listener, () -> { | ||
replica.commitTransaction(request.txid()); | ||
return new ReplicaResult(); | ||
}); | ||
} | ||
} |
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