Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import javax.sql.DataSource;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.Provider;
Expand All @@ -30,6 +32,9 @@
*/
public class DefaultDataSourceProvider implements Provider<DataSource> {

private static final Logger LOG =
LoggerFactory.getLogger(DefaultDataSourceProvider.class);

@Inject
private DataSourceConfiguration configuration;

Expand All @@ -43,6 +48,7 @@ public class DefaultDataSourceProvider implements Provider<DataSource> {
@Override
public DataSource get() {
String jdbcUrl = configuration.getJdbcUrl();
LOG.info("JDBC Url for Recon : {} ", jdbcUrl);
if (StringUtils.contains(jdbcUrl, "derby")) {
return new DerbyDataSourceProvider(configuration).get();
} else if (StringUtils.contains(jdbcUrl, "sqlite")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class DerbyDataSourceProvider implements Provider<DataSource> {
@Override
public DataSource get() {
String jdbcUrl = configuration.getJdbcUrl();
LOG.info("JDBC Url for Recon : {} ", jdbcUrl);
try {
createNewDerbyDatabase(jdbcUrl, RECON_SCHEMA_NAME);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public Pair<String, Boolean> reprocess(OMMetadataManager omMetadataManager) {
return new ImmutablePair<>(getTaskName(), false);
}
// Truncate table before inserting new rows
dslContext.truncate(FILE_COUNT_BY_SIZE);
int execute = dslContext.delete(FILE_COUNT_BY_SIZE).execute();
LOG.info("Deleted {} records from {}", execute, FILE_COUNT_BY_SIZE);

writeCountsToDB(true, fileSizeCountMap);

LOG.info("Completed a 'reprocess' run of FileSizeCountTask.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static java.util.stream.Collectors.toList;
import static org.apache.hadoop.ozone.recon.ReconControllerModule.ReconDaoBindingModule.RECON_DAO_LIST;
import static org.hadoop.ozone.recon.codegen.SqlDbUtils.SQLITE_DRIVER_CLASS;
import static org.hadoop.ozone.recon.schema.Tables.RECON_TASK_STATUS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

Expand Down Expand Up @@ -76,6 +77,10 @@ public void testSchemaSetup() throws SQLException {
ReconTaskStatusDao dao = getDao(ReconTaskStatusDao.class);
dao.insert(new ReconTaskStatus("TestTask", 1L, 2L));
assertEquals(1, dao.findAll().size());

int numRows = getDslContext().delete(RECON_TASK_STATUS).execute();
assertEquals(1, numRows);
assertEquals(0, dao.findAll().size());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.hadoop.ozone.recon.tasks.OMDBUpdateEvent.OMUpdateEventBuilder;
import org.hadoop.ozone.recon.schema.UtilizationSchemaDefinition;
import org.hadoop.ozone.recon.schema.tables.daos.FileCountBySizeDao;
import org.hadoop.ozone.recon.schema.tables.pojos.FileCountBySize;
import org.jooq.DSLContext;
import org.jooq.Record3;
import org.junit.Before;
Expand Down Expand Up @@ -111,6 +112,11 @@ public void testReprocess() throws IOException {
.thenReturn(omKeyInfo2)
.thenReturn(omKeyInfo3);

// Reprocess could be called from table having existing entries. Adding
// an entry to simulate that.
fileCountBySizeDao.insert(
new FileCountBySize("vol1", "bucket1", 1024L, 10L));

Pair<String, Boolean> result =
fileSizeCountTask.reprocess(omMetadataManager);
assertTrue(result.getRight());
Expand Down