forked from sofastack/sofa-jraft
-
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.
* [rpc-adapter] add rpc interface * [rpc-adapter] add rpc interface * [rpc-adapter] clear direct dependencies of bolt * [rpc-adapter] add grpc impl [WIP]
- Loading branch information
1 parent
6b66aa6
commit 2d04955
Showing
107 changed files
with
1,993 additions
and
769 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ | |
import com.alipay.sofa.jraft.rpc.CliRequests.SnapshotRequest; | ||
import com.alipay.sofa.jraft.rpc.CliRequests.TransferLeaderRequest; | ||
import com.alipay.sofa.jraft.rpc.RpcRequests.ErrorResponse; | ||
import com.alipay.sofa.jraft.rpc.impl.cli.BoltCliClientService; | ||
import com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl; | ||
import com.alipay.sofa.jraft.util.Requires; | ||
import com.alipay.sofa.jraft.util.Utils; | ||
import com.google.protobuf.Message; | ||
|
@@ -67,8 +67,7 @@ | |
* Cli service implementation. | ||
* | ||
* @author boyan ([email protected]) | ||
* | ||
* 2018-Apr-09 4:12:06 PM | ||
* @author jiachun.fjc | ||
*/ | ||
public class CliServiceImpl implements CliService { | ||
|
||
|
@@ -85,7 +84,7 @@ public synchronized boolean init(final CliOptions opts) { | |
return true; | ||
} | ||
this.cliOptions = opts; | ||
this.cliClientService = new BoltCliClientService(); | ||
this.cliClientService = new CliClientServiceImpl(); | ||
return this.cliClientService.init(this.cliOptions); | ||
} | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
jraft-core/src/main/java/com/alipay/sofa/jraft/error/InvokeTimeoutException.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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 com.alipay.sofa.jraft.error; | ||
|
||
/** | ||
* @author jiachun.fjc | ||
*/ | ||
public class InvokeTimeoutException extends RemotingException { | ||
|
||
private static final long serialVersionUID = -4710810309766380565L; | ||
|
||
public InvokeTimeoutException() { | ||
} | ||
|
||
public InvokeTimeoutException(String message) { | ||
super(message); | ||
} | ||
|
||
public InvokeTimeoutException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public InvokeTimeoutException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public InvokeTimeoutException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
jraft-core/src/main/java/com/alipay/sofa/jraft/error/RemotingException.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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 com.alipay.sofa.jraft.error; | ||
|
||
/** | ||
* Exception for default remoting problems. | ||
* | ||
* @author jiachun.fjc | ||
*/ | ||
public class RemotingException extends Exception { | ||
|
||
private static final long serialVersionUID = -6326244159775972292L; | ||
|
||
public RemotingException() { | ||
} | ||
|
||
public RemotingException(String message) { | ||
super(message); | ||
} | ||
|
||
public RemotingException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public RemotingException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public RemotingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
} |
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
jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/Connection.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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 com.alipay.sofa.jraft.rpc; | ||
|
||
/** | ||
* @author jiachun.fjc | ||
*/ | ||
public interface Connection { | ||
|
||
/** | ||
* Get the attribute that bound to the connection. | ||
* | ||
* @param key the attribute key | ||
* @return the attribute value | ||
*/ | ||
Object getAttribute(final String key); | ||
|
||
/** | ||
* Set the attribute to the connection. | ||
* | ||
* @param key the attribute key | ||
* @param value the attribute value | ||
*/ | ||
void setAttribute(final String key, final Object value); | ||
|
||
/** | ||
* Close the connection. | ||
*/ | ||
void close(); | ||
} |
29 changes: 29 additions & 0 deletions
29
jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/InvokeCallback.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,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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 com.alipay.sofa.jraft.rpc; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* @author jiachun.fjc | ||
*/ | ||
public interface InvokeCallback { | ||
|
||
void complete(final Object result, final Throwable err); | ||
|
||
Executor executor(); | ||
} |
56 changes: 56 additions & 0 deletions
56
jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/InvokeContext.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,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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 com.alipay.sofa.jraft.rpc; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
/** | ||
* RPC invoke context. | ||
* | ||
* @author jiachun.fjc | ||
*/ | ||
public class InvokeContext { | ||
|
||
public final static String CRC_SWITCH = "invoke.crc.switch"; | ||
|
||
private final ConcurrentMap<String, Object> ctx = new ConcurrentHashMap<>(); | ||
|
||
public Object put(final String key, final Object value) { | ||
return this.ctx.put(key, value); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> T get(final String key) { | ||
return (T) this.ctx.get(key); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> T getOrDefault(final String key, final T defaultValue) { | ||
return (T) this.ctx.getOrDefault(key, defaultValue); | ||
} | ||
|
||
public void clear() { | ||
this.ctx.clear(); | ||
} | ||
|
||
public Set<Map.Entry<String, Object>> entrySet() { | ||
return this.ctx.entrySet(); | ||
} | ||
} |
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.