use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class ChangeSetManager method getExecutedChangeSets.
/**
* Returns a new list of {@link ChangeSet} that has already been executed as specified by {@code schemaChangeLogs}.
*
* @param schemaChangeLogs logs of change sets already executed
* @return a list of change sets already executed
* @throws IllegalArgumentException if the current change sets are not valid for the specified{@code schemaChangeLogs}
*/
public List<ChangeSet> getExecutedChangeSets(List<SchemaChangeLog> schemaChangeLogs) {
if (CollectionUtils.isEmpty(schemaChangeLogs)) {
return Collections.emptyList();
}
List<SchemaChangeLog> sortedSchemaChangeLogs = sortSchemaChangeLogs(schemaChangeLogs);
List<ChangeSet> executedChangeSets = new ArrayList<>();
for (int i = 0; i < changeSets.size() && i < sortedSchemaChangeLogs.size(); i++) {
ChangeSet changeSet = changeSets.get(i);
SchemaChangeLog executedSchemaChangeLog = sortedSchemaChangeLogs.get(i);
int expectedOrder = i + 1;
verifyChangeLog(executedSchemaChangeLog, changeSet, expectedOrder);
executedChangeSets.add(changeSet);
}
return executedChangeSets;
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class ChangeSetManager method filterExecutedChangeSets.
/**
* Returns a new list of {@link ChangeSet} that has not been executed as specified by {@code schemaChangeLogs}.
*
* @param schemaChangeLogs logs of change sets already executed
* @return a list of change sets not yet executed
* @throws IllegalArgumentException if the current change sets are not valid for the specified{@code schemaChangeLogs}
*/
public List<ChangeSet> filterExecutedChangeSets(List<SchemaChangeLog> schemaChangeLogs) {
if (CollectionUtils.isEmpty(schemaChangeLogs)) {
return new ArrayList<>(changeSets);
}
List<SchemaChangeLog> sortedSchemaChangeLogs = sortSchemaChangeLogs(schemaChangeLogs);
int i = 0;
while (i < changeSets.size() && i < sortedSchemaChangeLogs.size()) {
ChangeSet changeSet = changeSets.get(i);
SchemaChangeLog executedSchemaChangeLog = sortedSchemaChangeLogs.get(i);
int expectedOrder = i + 1;
verifyChangeLog(executedSchemaChangeLog, changeSet, expectedOrder);
i++;
}
if (i >= changeSets.size()) {
return Collections.emptyList();
}
return new ArrayList<>(changeSets.subList(i, changeSets.size()));
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class HbaseSchemaServiceImplTest method getSchemaStatus_validSchemaChangeLogs.
@Test
public void getSchemaStatus_validSchemaChangeLogs() {
final String namespace = "namespace";
final List<ChangeSet> changeSets = Arrays.asList(newChangeSet("id1", "value1"), newChangeSet("id2", "value2"), newChangeSet("id3", "value3"));
final List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value1", 1), newSchemaChangeLog("id2", "value2", 2), newSchemaChangeLog("id3", "value3", 3));
when(schemaChangeLogService.isAvailable(namespace)).thenReturn(true);
when(schemaChangeLogService.getSchemaChangeLogs(namespace)).thenReturn(schemaChangeLogs);
HbaseSchemaStatus schemaStatus = hbaseSchemaService.getSchemaStatus(namespace, changeSets);
MatcherAssert.assertThat(schemaStatus, is(HbaseSchemaStatus.VALID));
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class HbaseSchemaServiceImplTest method getSchemaStatus_invalidSchemaChangeLogs.
@Test
public void getSchemaStatus_invalidSchemaChangeLogs() {
final String namespace = "namespace";
final List<ChangeSet> changeSets = Arrays.asList(newChangeSet("id1", "value1"), newChangeSet("id2", "value2"), newChangeSet("id3", "value3"));
final List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value2", 2), newSchemaChangeLog("id2", "value1", 1), newSchemaChangeLog("someOtherId", "value3", 3));
when(schemaChangeLogService.isAvailable(namespace)).thenReturn(true);
when(schemaChangeLogService.getSchemaChangeLogs(namespace)).thenReturn(schemaChangeLogs);
HbaseSchemaStatus schemaStatus = hbaseSchemaService.getSchemaStatus(namespace, changeSets);
MatcherAssert.assertThat(schemaStatus, is(HbaseSchemaStatus.INVALID));
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class ChangeSetManagerTest method filterExecutedChangeSets_largerSchemaChangeLogs.
@Test
public void filterExecutedChangeSets_largerSchemaChangeLogs() {
ChangeSet changeSet = newChangeSet("id1", "value1");
ChangeSetManager changeSetManager = new ChangeSetManager(Arrays.asList(changeSet));
List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value1", 1), newSchemaChangeLog("id2", "value2", 2));
List<ChangeSet> unexecutedChangeSets = changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
assertThat(unexecutedChangeSets, is(empty()));
}
Aggregations