Skip to content

Commit

Permalink
Merge branch 'integration' into task/resilient-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mineralntl authored Jan 10, 2025
2 parents 4c9e36a + 99ae8d6 commit 68427e2
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import datawave.data.type.Type;
import datawave.marking.MarkingFunctions;
import datawave.marking.MarkingFunctionsFactory;
import datawave.webservice.query.cachedresults.CacheableQueryRow;
import datawave.webservice.query.data.ObjectSizeOf;
import datawave.webservice.query.util.TypedValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public class DateIndexDataTypeHandler<KEYIN> implements DataTypeHandler<KEYIN>,
public static final String DATEINDEX_TNAME = "date.index.table.name";
public static final String DATEINDEX_LPRIORITY = "date.index.table.loader.priority";

private static final MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();

// comma delimited <date type>=<field name> values
public static final String DATEINDEX_TYPE_TO_FIELDS = ".date.index.type.to.field.map";

Expand Down Expand Up @@ -367,7 +365,7 @@ private Value createDateIndexValue(int shard) {
* @return the flattened visibility
*/
protected byte[] flatten(ColumnVisibility vis) {
return markingFunctions.flatten(vis);
return MarkingFunctions.Factory.createMarkingFunctions().flatten(vis);
}

public Text getDateIndexTableName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class CSVRecordReader extends CSVReaderBase implements EventFixer {
private static final Logger log = Logger.getLogger(CSVRecordReader.class);

private static final IngestConfiguration ingestConfig = IngestConfigurationFactory.getIngestConfiguration();
private static final MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();

protected String csvEventId;
private final Multimap<String,Object> metadataForValidation = ArrayListMultimap.create(100, 1);
Expand Down Expand Up @@ -128,7 +127,7 @@ protected void decorateEvent() {
if (null != this.securityMarkings && !this.securityMarkings.isEmpty()) {
event.setSecurityMarkings(securityMarkings);
try {
event.setVisibility(markingFunctions.translateToColumnVisibility(securityMarkings));
event.setVisibility(MarkingFunctionsFactory.createMarkingFunctions().translateToColumnVisibility(securityMarkings));
} catch (MarkingFunctions.Exception e) {
log.error("Could not set default ColumnVisibility for the event", e);
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public class FieldIndexCountingIteratorPerVisibility extends WrappingIterator im

private Set<ColumnVisibility> columnVisibilities = Sets.newHashSet();
private TreeMap<Key,Value> keyCache = null;
protected static final MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();

// -------------------------------------------------------------------------
// ------------- Constructors
Expand Down Expand Up @@ -566,7 +565,7 @@ private Map<Key,Value> buildReturnKeys() {
ColumnVisibility cv = null;
try {
// Calculate the columnVisibility for this key from the combiner.
cv = markingFunctions.combine(columnVisibilities);
cv = MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);
} catch (Exception e) {
log.error("Could not create combined columnVisibility for the count", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class GlobalIndexDateSummaryIterator implements SortedKeyValueIterator<Ke
protected Value returnValue = null;
protected SortedMap<Key,Value> returnCache = new TreeMap<>();
protected Set<ColumnVisibility> columnVisibilities = Sets.newHashSet();
private static MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();

public GlobalIndexDateSummaryIterator() {}

Expand Down Expand Up @@ -257,7 +256,7 @@ public Map<Key,Value> getKeyValues() throws IOException {
Set<ColumnVisibility> columnVisibilities = this.columnVisibilitiesMap.get(datatype);

// Note that the access controls found in the combined ColumnVisibility will be pulled out appropriately here
ColumnVisibility cv = markingFunctions.combine(columnVisibilities);
ColumnVisibility cv = MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);

// Create a new Key compatible with the shardIndex key format
Key k = new Key(this.fieldValue, this.fieldName, this.date + '\0' + datatype, new String(cv.getExpression()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public long read() {

private String threadName = null;
protected Set<ColumnVisibility> columnVisibilities = Sets.newHashSet();
private static MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();

public ResultCountingIterator() {
threadName = Thread.currentThread().getName();
Expand Down Expand Up @@ -210,7 +209,7 @@ public Value getTopValue() {
ColumnVisibility cv = null;

try {
cv = markingFunctions.combine(columnVisibilities);
cv = MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);
} catch (MarkingFunctions.Exception e) {
log.error("Could not create combined columnVisibility for the count", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import datawave.marking.MarkingFunctions;
import datawave.marking.MarkingFunctions.Exception;
import datawave.marking.MarkingFunctionsFactory;

public abstract class AttributeBag<T extends Comparable<T>> extends Attribute<T> implements Serializable {

Expand All @@ -23,10 +22,8 @@ public abstract class AttributeBag<T extends Comparable<T>> extends Attribute<T>

private static final long ONE_DAY_MS = 1000l * 60 * 60 * 24;

protected static final MarkingFunctions markingFunctions = MarkingFunctionsFactory.createMarkingFunctions();

public MarkingFunctions getMarkingFunctions() {
return markingFunctions;
return MarkingFunctions.Factory.createMarkingFunctions();
}

protected AttributeBag() {
Expand Down Expand Up @@ -83,7 +80,7 @@ protected ColumnVisibility combineAndSetColumnVisibilities(Collection<Attribute<
for (Attribute<?> attr : attributes) {
columnVisibilities.add(attr.getColumnVisibility());
}
return AttributeBag.markingFunctions.combine(columnVisibilities);
return MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);
}

private long updateTimestamps() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class TermInfoAggregation implements Function<Collection<TermInfo>,Discov

private static final Logger log = Logger.getLogger(TermInfoAggregation.class);
private Set<ColumnVisibility> columnVisibilities = Sets.newHashSet();
private static MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();
private final boolean separateCountsByColumnVisibility;
private boolean showReferenceCountInsteadOfTermCount = false;
private boolean reverseIndex = false;
Expand Down Expand Up @@ -74,7 +73,7 @@ public DiscoveredThing apply(Collection<TermInfo> from) {
chosenCount = showReferenceCountInsteadOfTermCount ? referenceCount : termCount;

try {
markingFunctions.translateFromColumnVisibility(ti.vis); // just to test parsing
MarkingFunctions.Factory.createMarkingFunctions().translateFromColumnVisibility(ti.vis); // just to test parsing
columnVisibilities.add(ti.vis);

// Keep track of counts for individual vis
Expand Down Expand Up @@ -108,7 +107,7 @@ public DiscoveredThing apply(Collection<TermInfo> from) {
ColumnVisibility columnVisibility = null;
try {

columnVisibility = markingFunctions.combine(columnVisibilities);
columnVisibility = MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);

} catch (Exception e) {
log.warn("Invalid columnvisibility after combining!", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public class FieldIndexCountingIterator extends WrappingIterator implements Sort

private Set<Text> visibilitySet = new HashSet<>();

protected static final MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();

// -------------------------------------------------------------------------
// ------------- Constructors
public FieldIndexCountingIterator() {
Expand Down Expand Up @@ -588,7 +586,7 @@ private Key buildReturnKey() {
}
ColumnVisibility cv;
try {
cv = markingFunctions.combine(columnVisibilities);
cv = MarkingFunctions.Factory.createMarkingFunctions().combine(columnVisibilities);
} catch (MarkingFunctions.Exception e) {
log.error("Could not combine visibilities: " + visibilitySet + " " + e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public class ShardTableQueryMetricHandler extends BaseQueryMetricHandler<QueryMe

private Collection<String> connectorAuthorizationCollection = null;
private String connectorAuthorizations = null;
private MarkingFunctions markingFunctions = null;

@SuppressWarnings("FieldCanBeLocal")
private final String JOB_ID = "job_201109071404_1";
Expand Down Expand Up @@ -165,7 +164,6 @@ public ShardTableQueryMetricHandler() {
String accumuloPassword = conf.get("AccumuloRecordWriter.password");
byte[] encodedAccumuloPassword = Base64.encodeBase64(accumuloPassword.getBytes());
conf.set("AccumuloRecordWriter.password", new String(encodedAccumuloPassword));
markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();
}

@PostConstruct
Expand Down Expand Up @@ -286,11 +284,12 @@ private Multimap<BulkIngestKey,Value> getEntries(AbstractColumnBasedHandler<Key>
event.setDate(storedQueryMetric.getCreateDate().getTime());
// get security markings from metric, otherwise default to PUBLIC
Map<String,String> markings = updatedQueryMetric.getMarkings();
if (markingFunctions == null || markings == null || markings.isEmpty()) {
if (markings == null || markings.isEmpty()) {
event.setVisibility(new ColumnVisibility(DEFAULT_SECURITY_MARKING));
} else {
try {
event.setVisibility(this.markingFunctions.translateToColumnVisibility(markings));
MarkingFunctions markingFunctions = MarkingFunctions.Factory.createMarkingFunctions();
event.setVisibility(markingFunctions.translateToColumnVisibility(markings));
} catch (Exception e) {
log.error(e.getMessage(), e);
event.setVisibility(new ColumnVisibility(DEFAULT_SECURITY_MARKING));
Expand Down

0 comments on commit 68427e2

Please sign in to comment.