当前位置: 首页>>代码示例>>Java>>正文


Java ProtocolVersion.V4属性代码示例

本文整理汇总了Java中com.datastax.driver.core.ProtocolVersion.V4属性的典型用法代码示例。如果您正苦于以下问题:Java ProtocolVersion.V4属性的具体用法?Java ProtocolVersion.V4怎么用?Java ProtocolVersion.V4使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.datastax.driver.core.ProtocolVersion的用法示例。


在下文中一共展示了ProtocolVersion.V4属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testWriteEmptyBatch

@Test
public void testWriteEmptyBatch() throws InterruptedException, StageException {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "time_id"),
      new CassandraFieldMappingConfig("[6]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  List<Record> emptyBatch = ImmutableList.of();
  targetRunner.runInit();
  targetRunner.runWrite(emptyBatch);
  targetRunner.runDestroy();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:30,代码来源:TestCassandraTarget.java

示例2: testMalformedTableName

@Test(expected = StageException.class)
public void testMalformedTableName() throws Exception {
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("/driver", "driver_id"),
      new CassandraFieldMappingConfig("/trip", "trip_id"),
      new CassandraFieldMappingConfig("/time", "time"),
      new CassandraFieldMappingConfig("/x", "x"),
      new CassandraFieldMappingConfig("/y", "y"),
      new CassandraFieldMappingConfig("/time_id", "time_id"),
      new CassandraFieldMappingConfig("/unique_id", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = "tableName";

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  targetRunner.runInit();
  fail("should have thrown a StageException!");
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:27,代码来源:TestCassandraTarget.java

示例3: testWriteSingleRecord

@Test
public void testWriteSingleRecord() throws InterruptedException, StageException {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "dt"),
      new CassandraFieldMappingConfig("[6]", "ts"),
      new CassandraFieldMappingConfig("[7]", "time_id"),
      new CassandraFieldMappingConfig("[8]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  long now = System.currentTimeMillis();
  LocalDate dt = LocalDate.fromMillisSinceEpoch(now);
  Date ts = new Date();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create(1));
  fields.add(Field.create(2));
  fields.add(Field.create(3));
  fields.add(Field.create(4.0));
  fields.add(Field.create(5.0));
  fields.add(Field.create(Field.Type.DATE, new Date(dt.getMillisSinceEpoch())));
  fields.add(Field.create(Field.Type.DATETIME, ts));
  fields.add(Field.create(SAMPLE_TIMEUUID));
  fields.add(Field.create(SAMPLE_UUID));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should not be any error records.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(1, allRows.size());

  Row row = allRows.get(0);
  Assert.assertEquals(1, row.getInt("driver_id"));
  Assert.assertEquals(2, row.getInt("trip_id"));
  Assert.assertEquals(3, row.getInt("time"));
  Assert.assertEquals(4.0, row.getDouble("x"), EPSILON);
  Assert.assertEquals(5.0, row.getDouble("y"), EPSILON);
  Assert.assertEquals(dt, row.getDate("dt"));
  Assert.assertEquals(ts, row.getTimestamp("ts"));
  Assert.assertEquals(SAMPLE_TIMEUUID, row.getUUID("time_id").toString());
  Assert.assertEquals(SAMPLE_UUID, row.getUUID("unique_id").toString());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:69,代码来源:TestCassandraTarget.java

示例4: testCollectionTypes

@Test
public void testCollectionTypes() throws InterruptedException, StageException {
  final String tableName = "test.collections";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "id"),
      new CassandraFieldMappingConfig("[1]", "a_list"),
      new CassandraFieldMappingConfig("[2]", "a_map")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create(1));
  fields.add(Field.create(ImmutableList.of(Field.create(2))));
  fields.add(Field.create(ImmutableMap.of("3", Field.create(4))));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should not be any error records.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.collections");
  List<Row> allRows = resultSet.all();
  assert (1 == allRows.size());

  Row row = allRows.get(0);
  assert (row.getInt("id") == 1);
  assert (row.getList("a_list", Integer.class).contains(2));
  assert (row.getMap("a_map", String.class, Integer.class).containsKey("3"));
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:47,代码来源:TestCassandraTarget.java

示例5: testWriteRecordsOnErrorDiscard

@Test
public void testWriteRecordsOnErrorDiscard() throws Exception {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "time_id"),
      new CassandraFieldMappingConfig("[6]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target)
      .setOnRecordError(OnRecordError.DISCARD)
      .build();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create(1.3));
  fields.add(Field.create(2));
  fields.add(Field.create(3));
  fields.add(Field.create(4.0));
  fields.add(Field.create(5.0));
  fields.add(Field.create(SAMPLE_TIMEUUID));
  fields.add(Field.create(SAMPLE_UUID));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should not be any error records if we are discarding.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(0, allRows.size());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:52,代码来源:TestCassandraTarget.java

示例6: testWriteRecordsOnErrorToError

@Test
public void testWriteRecordsOnErrorToError() throws Exception {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "time_id"),
      new CassandraFieldMappingConfig("[6]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target)
      .setOnRecordError(OnRecordError.TO_ERROR)
      .build();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create(1.3));
  fields.add(Field.create(2));
  fields.add(Field.create(3));
  // intentionally passing doubles where these values are expected to be ints triggers errors!
  fields.add(Field.create(4.0));
  fields.add(Field.create(5.0));
  fields.add(Field.create(SAMPLE_TIMEUUID));
  fields.add(Field.create(SAMPLE_UUID));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should have gone to error pipeline
  Assert.assertEquals(1, targetRunner.getErrorRecords().size());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(0, allRows.size());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:53,代码来源:TestCassandraTarget.java

示例7: testWriteRecordsOnErrorStopPipeline

@Test(expected = StageException.class)
public void testWriteRecordsOnErrorStopPipeline() throws Exception {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "time_id"),
      new CassandraFieldMappingConfig("[6]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target)
      .setOnRecordError(OnRecordError.STOP_PIPELINE)
      .build();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create(1.3));
  fields.add(Field.create(2));
  fields.add(Field.create(3));
  fields.add(Field.create(4.0));
  fields.add(Field.create(5.0));
  fields.add(Field.create(SAMPLE_TIMEUUID));
  fields.add(Field.create(SAMPLE_UUID));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should have gone to error pipeline
  Assert.assertEquals(1, targetRunner.getErrorRecords().size());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(0, allRows.size());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:52,代码来源:TestCassandraTarget.java

示例8: testWriteRecordWithMissingFields

@Test
public void testWriteRecordWithMissingFields() throws InterruptedException, StageException {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("/driver", "driver_id"),
      new CassandraFieldMappingConfig("/trip", "trip_id"),
      new CassandraFieldMappingConfig("/time", "time"),
      new CassandraFieldMappingConfig("/x", "x"),
      new CassandraFieldMappingConfig("/y", "y"),
      new CassandraFieldMappingConfig("/time_id", "time_id"),
      new CassandraFieldMappingConfig("/unique_id", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  Record record = RecordCreator.create();
  Map<String, Field> fields = new ImmutableMap.Builder<String, Field>()
      .put("driver", Field.create(1))
      .put("trip", Field.create(2))
      .put("time", Field.create(3))
      .put("y", Field.create(5.0))
      .put("time_id", Field.create(SAMPLE_TIMEUUID))
      .put("unique_id", Field.create(SAMPLE_UUID))
      .build();
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should not be any error records.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(1, allRows.size());

  Row row = allRows.get(0);
  Assert.assertEquals(1, row.getInt("driver_id"));
  Assert.assertEquals(2, row.getInt("trip_id"));
  Assert.assertEquals(3, row.getInt("time"));
  Assert.assertEquals(null, row.getBytesUnsafe("x"));
  Assert.assertEquals(5.0, row.getDouble("y"), EPSILON);
  Assert.assertEquals(SAMPLE_TIMEUUID, row.getUUID("time_id").toString());
  Assert.assertEquals(SAMPLE_UUID, row.getUUID("unique_id").toString());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:59,代码来源:TestCassandraTarget.java

示例9: testInternalSubBatching

@Test
public void testInternalSubBatching() throws Exception {
  final String tableName = "test.trips";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(
      new CassandraFieldMappingConfig("[0]", "driver_id"),
      new CassandraFieldMappingConfig("[1]", "trip_id"),
      new CassandraFieldMappingConfig("[2]", "time"),
      new CassandraFieldMappingConfig("[3]", "x"),
      new CassandraFieldMappingConfig("[4]", "y"),
      new CassandraFieldMappingConfig("[5]", "time_id"),
      new CassandraFieldMappingConfig("[6]", "unique_id")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;
  conf.maxBatchSize = 35;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  List<Record> records = new ArrayList<>();
  for (int i = 0; i < 1000; i++) {
    Record record = RecordCreator.create();
    List<Field> fields = new ArrayList<>();
    fields.add(Field.create(i));
    fields.add(Field.create(2));
    fields.add(Field.create(3));
    fields.add(Field.create(4.0));
    fields.add(Field.create(5.0));
    fields.add(Field.create(SAMPLE_TIMEUUID));
    fields.add(Field.create(SAMPLE_UUID));
    record.set(Field.create(fields));
    records.add(record);
  }
  targetRunner.runInit();
  targetRunner.runWrite(records);

  // Should not be any error records.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  // simple verification that there are as many records as expected
  ResultSet resultSet = session.execute("SELECT * FROM test.trips");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(1000, allRows.size());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:54,代码来源:TestCassandraTarget.java

示例10: testWriteNullValuedColumns

@Test
public void testWriteNullValuedColumns() throws Exception {
  final String tableName = "test.test_null_values";
  List<CassandraFieldMappingConfig> fieldMappings = ImmutableList.of(new CassandraFieldMappingConfig("[0]", "a"),
      new CassandraFieldMappingConfig("[1]", "b")
  );

  CassandraTargetConfig conf = new CassandraTargetConfig();
  conf.contactPoints.add("localhost");
  conf.port = CASSANDRA_NATIVE_PORT;
  conf.protocolVersion = ProtocolVersion.V4;
  conf.authProviderOption = AuthProviderOption.NONE;
  conf.compression = CassandraCompressionCodec.NONE;
  conf.columnNames = fieldMappings;
  conf.qualifiedTableName = tableName;

  Target target = new CassandraTarget(conf);
  TargetRunner targetRunner = new TargetRunner.Builder(CassandraDTarget.class, target).build();

  Record record = RecordCreator.create();
  List<Field> fields = new ArrayList<>();
  fields.add(Field.create("abc"));
  fields.add(Field.create(Field.Type.STRING, null));
  record.set(Field.create(fields));

  List<Record> singleRecord = ImmutableList.of(record);
  targetRunner.runInit();
  targetRunner.runWrite(singleRecord);

  // Should not be any error records.
  Assert.assertTrue(targetRunner.getErrorRecords().isEmpty());
  Assert.assertTrue(targetRunner.getErrors().isEmpty());

  targetRunner.runDestroy();

  ResultSet resultSet = session.execute("SELECT * FROM test.test_null_values");
  List<Row> allRows = resultSet.all();
  Assert.assertEquals(1, allRows.size());

  Row row = allRows.get(0);
  Assert.assertEquals("abc", row.getString("a"));
  Assert.assertEquals(null, row.getString("b"));
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:43,代码来源:TestCassandraTarget.java


注:本文中的com.datastax.driver.core.ProtocolVersion.V4属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。