Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started integration of new coordinator in the network layer
- Loading branch information
Showing
23 changed files
with
594 additions
and
8 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
28 changes: 26 additions & 2 deletions
28
...com/orientechnologies/orient/server/distributed/impl/coordinator/ODistributedChannel.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 |
---|---|---|
@@ -1,9 +1,33 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator; | ||
|
||
public interface ODistributedChannel { | ||
/** | ||
* Send submit request, that should go only to coordinator. | ||
* | ||
* @param request the request | ||
*/ | ||
void submit(OSubmitRequest request); | ||
|
||
/** | ||
* Send submit response, this is sent from the coordinator to the node that sent a submit request. | ||
* | ||
* @param response | ||
*/ | ||
void reply(OSubmitResponse response); | ||
|
||
/** | ||
* Send an operation to the node this is used by the coordinator to send operations of the distributed flow. | ||
* | ||
* @param id | ||
* @param nodeRequest | ||
*/ | ||
void sendRequest(OLogId id, ONodeRequest nodeRequest); | ||
|
||
/** | ||
* Send the response back to the coordinator, this is used by nodes to send a reply to a node request. | ||
* | ||
* @param id | ||
* @param nodeResponse | ||
*/ | ||
void sendResponse(OLogId id, ONodeResponse nodeResponse); | ||
|
||
void reply(OSubmitResponse response); | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/com/orientechnologies/orient/server/distributed/impl/coordinator/OLogId.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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator; | ||
|
||
import java.io.*; | ||
|
||
public class OLogId { | ||
private long id; | ||
|
||
public OLogId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public static void serialize(OLogId id, DataOutput output) throws IOException { | ||
output.writeLong(id.id); | ||
} | ||
|
||
public static OLogId deserialize(DataInput input) throws IOException { | ||
return new OLogId(input.readLong()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...java/com/orientechnologies/orient/server/distributed/impl/coordinator/OSubmitContext.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,6 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator; | ||
|
||
public interface OSubmitContext { | ||
|
||
void receive(OSubmitResponse response); | ||
} |
5 changes: 5 additions & 0 deletions
5
...ava/com/orientechnologies/orient/server/distributed/impl/coordinator/OSubmitResponse.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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator; | ||
|
||
import java.io.*; | ||
|
||
public interface OSubmitResponse { | ||
void serialize(DataOutput output) throws IOException; | ||
|
||
void deserialize(DataInput input) throws IOException; | ||
} |
12 changes: 12 additions & 0 deletions
12
...technologies/orient/server/distributed/impl/coordinator/network/OCoordinatedExecutor.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,12 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
public interface OCoordinatedExecutor { | ||
|
||
void executeOperationRequest(OOperationRequest request); | ||
|
||
void executeOperationResponse(OOperationResponse response); | ||
|
||
void executeSubmitResponse(ONetworkSubmitResponse response); | ||
|
||
void executeSubmitRequest(ONetworkSubmitRequest request); | ||
} |
39 changes: 39 additions & 0 deletions
39
...orient/server/distributed/impl/coordinator/network/ODistributedChannelBinaryProtocol.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 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
import com.orientechnologies.orient.server.distributed.ORemoteServerController; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.*; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.network.ONetworkSubmitRequest; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.network.ONetworkSubmitResponse; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.network.OOperationRequest; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.network.OOperationResponse; | ||
|
||
public class ODistributedChannelBinaryProtocol implements ODistributedChannel { | ||
|
||
private ORemoteServerController controller; | ||
|
||
public ODistributedChannelBinaryProtocol(ORemoteServerController controller) { | ||
this.controller = controller; | ||
} | ||
|
||
@Override | ||
public void sendRequest(OLogId id, ONodeRequest nodeRequest) { | ||
controller.sendBinaryRequest(new OOperationRequest(id, nodeRequest)); | ||
} | ||
|
||
@Override | ||
public void sendResponse(OLogId id, ONodeResponse nodeResponse) { | ||
controller.sendBinaryRequest(new OOperationResponse(id, nodeResponse)); | ||
|
||
} | ||
|
||
@Override | ||
public void submit(OSubmitRequest request) { | ||
controller.sendBinaryRequest(new ONetworkSubmitRequest(request)); | ||
} | ||
|
||
@Override | ||
public void reply(OSubmitResponse response) { | ||
controller.sendBinaryRequest(new ONetworkSubmitResponse(response)); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...chnologies/orient/server/distributed/impl/coordinator/network/ODistributedExecutable.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,6 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
public interface ODistributedExecutable { | ||
|
||
void executeDistributed(OCoordinatedExecutor executor); | ||
} |
73 changes: 73 additions & 0 deletions
73
...echnologies/orient/server/distributed/impl/coordinator/network/ONetworkSubmitRequest.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,73 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
import com.orientechnologies.orient.client.binary.OBinaryRequestExecutor; | ||
import com.orientechnologies.orient.client.remote.OBinaryRequest; | ||
import com.orientechnologies.orient.client.remote.OBinaryResponse; | ||
import com.orientechnologies.orient.client.remote.OStorageRemoteSession; | ||
import com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializer; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataInput; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataOutput; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.OSubmitRequest; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
import static com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryProtocol.DISTRIBUTED_SUBMIT_REQUEST; | ||
|
||
public class ONetworkSubmitRequest implements OBinaryRequest, ODistributedExecutable { | ||
private OSubmitRequest request; | ||
|
||
public ONetworkSubmitRequest(OSubmitRequest request) { | ||
this.request = request; | ||
} | ||
|
||
public ONetworkSubmitRequest() { | ||
|
||
} | ||
|
||
@Override | ||
public void write(OChannelDataOutput network, OStorageRemoteSession session) throws IOException { | ||
request.serialize(new DataOutputStream(network.getDataOutput())); | ||
} | ||
|
||
@Override | ||
public void read(OChannelDataInput channel, int protocolVersion, ORecordSerializer serializer) throws IOException { | ||
request = null;// TODO: create instance from a ID. | ||
request.deserialize(new DataInputStream(channel.getDataInput())); | ||
} | ||
|
||
@Override | ||
public byte getCommand() { | ||
return DISTRIBUTED_SUBMIT_REQUEST; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse createResponse() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse execute(OBinaryRequestExecutor executor) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Execution request to the coordinator"; | ||
} | ||
|
||
@Override | ||
public boolean requireDatabaseSession() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void executeDistributed(OCoordinatedExecutor executor) { | ||
executor.executeSubmitRequest(this); | ||
} | ||
|
||
public OSubmitRequest getRequest() { | ||
return request; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...chnologies/orient/server/distributed/impl/coordinator/network/ONetworkSubmitResponse.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,71 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
import com.orientechnologies.orient.client.binary.OBinaryRequestExecutor; | ||
import com.orientechnologies.orient.client.remote.OBinaryRequest; | ||
import com.orientechnologies.orient.client.remote.OBinaryResponse; | ||
import com.orientechnologies.orient.client.remote.OStorageRemoteSession; | ||
import com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializer; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataInput; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataOutput; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.OSubmitResponse; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
import static com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryProtocol.DISTRIBUTED_SUBMIT_RESPONSE; | ||
|
||
public class ONetworkSubmitResponse implements OBinaryRequest,ODistributedExecutable { | ||
private OSubmitResponse response; | ||
|
||
public ONetworkSubmitResponse() { | ||
} | ||
|
||
public ONetworkSubmitResponse(OSubmitResponse response) { | ||
this.response = response; | ||
} | ||
|
||
@Override | ||
public void write(OChannelDataOutput network, OStorageRemoteSession session) throws IOException { | ||
response.serialize(new DataOutputStream(network.getDataOutput())); | ||
} | ||
|
||
@Override | ||
public void read(OChannelDataInput channel, int protocolVersion, ORecordSerializer serializer) throws IOException { | ||
response = null;//TODO: create instance from factory. | ||
response.deserialize(new DataInputStream(channel.getDataInput())); | ||
} | ||
|
||
@Override | ||
public byte getCommand() { | ||
return DISTRIBUTED_SUBMIT_RESPONSE; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse createResponse() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse execute(OBinaryRequestExecutor executor) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "execution response from coordinator"; | ||
} | ||
|
||
public boolean requireDatabaseSession() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void executeDistributed(OCoordinatedExecutor executor) { | ||
executor.executeSubmitResponse(this); | ||
} | ||
|
||
public OSubmitResponse getResponse() { | ||
return response; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...ientechnologies/orient/server/distributed/impl/coordinator/network/OOperationRequest.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,85 @@ | ||
package com.orientechnologies.orient.server.distributed.impl.coordinator.network; | ||
|
||
import com.orientechnologies.orient.client.binary.OBinaryRequestExecutor; | ||
import com.orientechnologies.orient.client.remote.OBinaryRequest; | ||
import com.orientechnologies.orient.client.remote.OBinaryResponse; | ||
import com.orientechnologies.orient.client.remote.OStorageRemoteSession; | ||
import com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializer; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataInput; | ||
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataOutput; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.OLogId; | ||
import com.orientechnologies.orient.server.distributed.impl.coordinator.ONodeRequest; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
import static com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryProtocol.DISTRIBUTED_OPERATION_REQUEST; | ||
|
||
public class OOperationRequest implements OBinaryRequest, ODistributedExecutable { | ||
private OLogId id; | ||
private ONodeRequest request; | ||
|
||
public OOperationRequest(OLogId id, ONodeRequest request) { | ||
this.id = id; | ||
this.request = request; | ||
} | ||
|
||
public OOperationRequest() { | ||
|
||
} | ||
|
||
@Override | ||
public void write(OChannelDataOutput network, OStorageRemoteSession session) throws IOException { | ||
DataOutputStream output = new DataOutputStream(network.getDataOutput()); | ||
OLogId.serialize(id, output); | ||
//TODO: write request kind/id. | ||
request.serialize(output); | ||
} | ||
|
||
@Override | ||
public void read(OChannelDataInput channel, int protocolVersion, ORecordSerializer serializer) throws IOException { | ||
DataInputStream input = new DataInputStream(channel.getDataInput()); | ||
id = OLogId.deserialize(input); | ||
request = null;// TODO: read the type id and create the instance. | ||
request.deserialize(input); | ||
} | ||
|
||
@Override | ||
public byte getCommand() { | ||
return DISTRIBUTED_OPERATION_REQUEST; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse createResponse() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OBinaryResponse execute(OBinaryRequestExecutor executor) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Distributed Operation Request/Response"; | ||
} | ||
|
||
@Override | ||
public boolean requireDatabaseSession() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void executeDistributed(OCoordinatedExecutor executor) { | ||
executor.executeOperationRequest(this); | ||
} | ||
|
||
public OLogId getId() { | ||
return id; | ||
} | ||
|
||
public ONodeRequest getRequest() { | ||
return request; | ||
} | ||
} |
Oops, something went wrong.