本文整理汇总了Java中com.couchbase.client.dcp.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于com.couchbase.client.dcp包,在下文中一共展示了Client类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CouchbaseStreamingConnection
import com.couchbase.client.dcp.Client; //导入依赖的package包/类
public CouchbaseStreamingConnection(String bootstrapNodes, String bucket, String password) {
connected = false;
streaming = false;
client = Client.configure()
.connectTimeout(10000L)
.hostnames(bootstrapNodes)
.bucket(bucket)
.password(password == null ? "" : password)
.controlParam(DcpControl.Names.CONNECTION_BUFFER_SIZE, 20480)
.bufferAckWatermark(60)
.build();
client.controlEventHandler(new ControlEventHandler() {
@Override
public void onEvent(ChannelFlowController controller, ByteBuf event) {
controller.ack(event);
event.release();
}
});
dataEventHandler = new EventHandler();
client.dataEventHandler(dataEventHandler);
}
示例2: init
import com.couchbase.client.dcp.Client; //导入依赖的package包/类
/**
* Link client with this handler
* @param client
*/
public void init(Client client)
{
log.info("configure {} as controEventHandler",Neo4jControlEventHandler.class.getName());
this.client = client;
client.controlEventHandler(this);
}
示例3: setup
import com.couchbase.client.dcp.Client; //导入依赖的package包/类
@Before
public void setup() {
PowerMockito.mockStatic(Client.class);
Builder builder = Mockito.mock(Builder.class);
Mockito.when(builder.connectTimeout(Mockito.anyLong())).thenReturn(builder);
Mockito.when(builder.hostnames(Mockito.anyString())).thenReturn(builder);
Mockito.when(builder.bucket(Mockito.anyString())).thenReturn(builder);
Mockito.when(builder.password(Mockito.anyString())).thenReturn(builder);
Mockito.when(builder.controlParam(Mockito.any(Names.class), Mockito.any())).thenReturn(builder);
Mockito.when(builder.bufferAckWatermark(Mockito.anyInt())).thenReturn(builder);
client = Mockito.mock(Client.class);
PowerMockito.when(Client.configure()).thenReturn(builder);
Mockito.when(builder.build()).thenReturn(client);
streamingConnection = new CouchbaseStreamingConnection("localhost", "", "testPassword");
}
示例4: main
import com.couchbase.client.dcp.Client; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
String configurationFile = System.getProperty("conf.file");
Validate.notBlank(configurationFile,"Use: -Dconf.file=<configuration_file>");
Neo4jSyncConfManager confManager = new PropertiesNeo4jSyncConfManager(configurationFile);
log.info("configure DCP client on {}[{}]",confManager.getCouchbaseHostname(),confManager.getCouchbaseBucket());
//TODO password?
// Connect to Couchbase DCP
final Client client = Client.configure()
.hostnames(confManager.getCouchbaseHostname())
.bucket(confManager.getCouchbaseBucket())
.build();
BoltNeo4jConnector connector = new BoltNeo4jConnector();
connector.init(confManager);
//FIXME manage rollback
Neo4jControlEventHandler controlEventHandler = new Neo4jControlEventHandler();
controlEventHandler.init(client);
log.info("configure BoltNeo4jConnector as neo4jConnector");
log.info("configure Neo4jDataEventHandler as dataEventHandler");
Neo4jDataEventHandler dataEventHandler = new Neo4jDataEventHandler();
dataEventHandler.setConnector(connector);
client.dataEventHandler(dataEventHandler);
// Connect the sockets
client.connect().await();
// Initialize the state (start now, never stop)
log.info("initialize stream from NOW to INFINITY");
client.initializeState(StreamFrom.NOW, StreamTo.INFINITY).await();
// Start streaming on all partitions
client.startStreaming().await();
//NEVER STOP
}