Comments (1)
"auto-compression" is not an accurate saying of this feature.
Background
Design
There's something more to discuss:
1. API Design
How to design the API? Can we make this feature backward compatible with the previous API? Is one more new method needed for every type of Pegasus RPC?
Since it's required to be backward compatible with API modified as minimum as possible, we provide this feature as a table-level option rather than a call-level option.
class TableOptions {
// Compression is one of the options.
bool enableCompression() {}
bool enableAutoRetry() {}
bool enableBackupRequest() {}
TableOptions withZstdCompression() {}
TableOptions withAutoRetry(int maxRetries, BackoffPolicy backoff) {}
TableOptions withBackupRequest(int backupRequestDelayMs) {}
}
class PegasusClientInterface {
PegasusTableInterface openTable(String tableName, TableOptions opts);
}
However, there may be some cases that users require finer-grained control over RPC.
For example:
- requests (within a table) for write (
multiset
) with auto-retry but read (multiget
) without retrying - requests (within a table) for one type of data with compression but others not.
2. Implementation Design
How can we design the API with as little modification of TableHandler
as possible? In other words, can we design TableHandler
to be more extensible, for features like compression or auto-retry?
One possible solution is to firstly refactor TableHandler, this refactoring suits go-client as well. It was inspired by grpc UnaryInterceptor and CallOption.
// TableInterceptor is a plugin to control the behavior of an RPC to a Pegasus table.
//
// request
// client ----> Pegasus Table
// |
// | ---- TableInterceptor is a middle layer to control the RPC process.
// |
// <----
// response
//
interface TableInterceptor {
// The behavior before the ReplicaSession sends the RPC.
void interceptBefore(ClientRequestRound rpc, TableHandler table, TableOptions opts) throws Exception;
// The behavior after the ReplicaSession get reply or failure of the RPC.
void interceptAfter(ClientRequestRound rpc, error_types errno, TableHandler table, TableOptions opts) Exception;
}
This is a simple implementation of interceptor of backup request.
class BackupRequestInterceptor implements TableInterceptor {
void interceptBefore(ClientRequestRound rpc, TableHandler table, TableOptions opts) throws Exception {
if (opts.enableBackupRequest()) {
rpc.backupRequestTask = executor.schedule();
}
}
void interceptAfter(ClientRequestRound rpc, TableHandler table, TableOptions opts) throws Exception {}
private int backupRequestDelayMs;
}
To implement compression:
class CompressionInterceptor implements TableInterceptor {
void interceptBefore(ClientRequestRound rpc, TableHandler table, TableOptions opts) throws Exception {
if(opts.enableCompression()) {
rpc.operator.compress();
}
}
void interceptAfter(ClientRequestRound rpc, TableHandler table, TableOptions opts) throws Exception {
if(opts.enableCompression()) {
rpc.operator.decompress();
}
}
}
Where are these interceptors registered? One possible mean is:
class TableHandler {
public TableHandler(ClusterManager mgr, String name, TableOptions options) {
...
interceptors.add(new CompressionInterceptor()).add(new BackupRequestInterceptor());
}
void call() {
for(TableInterceptor interceptor : interceptors) {
interceptor.interceptBefore();
}
primarySession.send( () -> {
for(TableInterceptor interceptor : interceptors) {
interceptor.interceptAfter();
}
}
}
private List<TableInterceptor> interceptors;
}
from pegasus-java-client.
Related Issues (20)
- Publish to the Central Repository? HOT 6
- Double-Checked Locking HOT 2
- Unreleased Resource: Streams
- Client API need be refactored and enhanced
- refactor and simplify the API HOT 4
- There is a vulnerability in guava 28.1-jre,upgrade recommended
- feature: backup request enhancement HOT 1
- fix extreme deadlock HOT 1
- bug: batchMultiGet may not fetch all data required by the input parameter
- feature: add a app create interface to the java client
- bug: netty rejected task with RejectedExecutionException
- remove log4j from dependencies. HOT 2
- bug
- bug: unable to reconnect a replica session HOT 1
- support backup request on client side HOT 5
- Unreleased Resource: Streams HOT 1
- Double-Checked Locking
- pegasus client logs need to be improved
- Forbid large-size-value writes to Pegasus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pegasus-java-client.