@Test public void testUpgradeAddColIfMissingColExists() { expect(sessionMock.getMetadata()).andReturn(metaMock); expect(metaMock.getKeyspace("jj_logging")).andReturn(Optional.of(ksMock)); expect(ksMock.getTable("foo")).andReturn(Optional.of(tableMock)); expect(tableMock.getColumn("bar")).andReturn(Optional.of(colMock)); replay(); manager.upgradeAddColIfMissing(sessionMock, "foo", "bar", "int"); }
@SuppressWarnings("SameParameterValue") void upgradeAddColIfMissing(CqlSession session, String tableName, String colName, String type) { Metadata metadata = session.getMetadata(); Optional<KeyspaceMetadata> jj_logging = metadata.getKeyspace("jj_logging"); jj_logging.ifPresent((keySpace) -> { Optional<TableMetadata> fault_tolerant = keySpace.getTable(tableName); fault_tolerant.ifPresent((table) -> { Optional<ColumnMetadata> error_count = table.getColumn(colName); if (error_count.isEmpty()) { System.out.println("Upgrading existing table to add error_count column."); String replace = UPGRADE_FT_TABLE_ADD_COL .replace("<T>", tableName) .replace("<C>", colName) .replace("<Y>", type); logger().info(replace); session.execute(replace); session.checkSchemaAgreement(); } }); }); }
CassandraLog4JManager extends AbstractManager { @SuppressWarnings("SameParameterValue") void upgradeAddColIfMissing(CqlSession session, String tableName, String colName, String type) { Metadata metadata = session.getMetadata(); Optional<KeyspaceMetadata> jj_logging = metadata.getKeyspace("jj_logging"); jj_logging.ifPresent((keySpace) -> { Optional<TableMetadata> fault_tolerant = keySpace.getTable(tableName); fault_tolerant.ifPresent((table) -> { Optional<ColumnMetadata> error_count = table.getColumn(colName); if (error_count.isEmpty()) { System.out.println("Upgrading existing table to add error_count column."); String replace = UPGRADE_FT_TABLE_ADD_COL .replace("<T>", tableName) .replace("<C>", colName) .replace("<Y>", type); logger().info(replace); session.execute(replace); session.checkSchemaAgreement(); } }); }); } }
CassandraLog4JManager extends AbstractManager { @SuppressWarnings("SameParameterValue") void upgradeAddColIfMissing(CqlSession session, String tableName, String colName, String type) { Metadata metadata = session.getMetadata(); Optional<KeyspaceMetadata> jj_logging = metadata.getKeyspace("jj_logging"); jj_logging.ifPresent((keySpace) -> { Optional<TableMetadata> fault_tolerant = keySpace.getTable(tableName); fault_tolerant.ifPresent((table) -> { Optional<ColumnMetadata> error_count = table.getColumn(colName); if (error_count.isEmpty()) { System.out.println("Upgrading existing table to add error_count column."); String replace = UPGRADE_FT_TABLE_ADD_COL .replace("<T>", tableName) .replace("<C>", colName) .replace("<Y>", type); logger().info(replace); session.execute(replace); session.checkSchemaAgreement(); } }); }); } protected  CassandraLog4JManager(String name); }
CassandraLog4JManager extends AbstractManager { @SuppressWarnings("SameParameterValue") void upgradeAddColIfMissing(CqlSession session, String tableName, String colName, String type) { Metadata metadata = session.getMetadata(); Optional<KeyspaceMetadata> jj_logging = metadata.getKeyspace("jj_logging"); jj_logging.ifPresent((keySpace) -> { Optional<TableMetadata> fault_tolerant = keySpace.getTable(tableName); fault_tolerant.ifPresent((table) -> { Optional<ColumnMetadata> error_count = table.getColumn(colName); if (error_count.isEmpty()) { System.out.println("Upgrading existing table to add error_count column."); String replace = UPGRADE_FT_TABLE_ADD_COL .replace("<T>", tableName) .replace("<C>", colName) .replace("<Y>", type); logger().info(replace); session.execute(replace); session.checkSchemaAgreement(); } }); }); } protected  CassandraLog4JManager(String name); boolean isReady(); }
CassandraLog4JManager extends AbstractManager { @SuppressWarnings("SameParameterValue") void upgradeAddColIfMissing(CqlSession session, String tableName, String colName, String type) { Metadata metadata = session.getMetadata(); Optional<KeyspaceMetadata> jj_logging = metadata.getKeyspace("jj_logging"); jj_logging.ifPresent((keySpace) -> { Optional<TableMetadata> fault_tolerant = keySpace.getTable(tableName); fault_tolerant.ifPresent((table) -> { Optional<ColumnMetadata> error_count = table.getColumn(colName); if (error_count.isEmpty()) { System.out.println("Upgrading existing table to add error_count column."); String replace = UPGRADE_FT_TABLE_ADD_COL .replace("<T>", tableName) .replace("<C>", colName) .replace("<Y>", type); logger().info(replace); session.execute(replace); session.checkSchemaAgreement(); } }); }); } protected  CassandraLog4JManager(String name); boolean isReady(); static final String CREATE_LOG_KEYSPACE; static final String CREATE_LOG_TABLE; static final String CREATE_FT_TABLE; static final String UPGRADE_FT_TABLE_ADD_COL; static final String FTI_STATUS_INDEX; static final String FTI_SCANNER_INDEX; }