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 @@ -62,8 +62,11 @@ public static void main(String[] args) throws Exception {

long t1 = System.currentTimeMillis();

long count = scanner.stream()
.peek(entry -> ContinuousWalk.validate(entry.getKey(), entry.getValue())).count();
long count = 0;
for (var entry : scanner) {
ContinuousWalk.validate(entry.getKey(), entry.getValue());
count++;
}
Comment on lines -66 to +69
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE was warning me that the .peek operation could possibly be optimized out by the compiler so I changed the syntax so that wouldnt happen


long t2 = System.currentTimeMillis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static java.nio.charset.StandardCharsets.UTF_8;

import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.SortedSet;
Expand Down Expand Up @@ -91,13 +90,10 @@ public void visit(State state, RandWalkEnv env, Properties props) throws Excepti
boolean ambiguousAuths =
WalkingSecurity.get(state, env).ambiguousAuthorizations(client.whoami());

Scanner scan = null;
try {
scan = client.createScanner(tableName, secOps.getUserAuthorizations(client.whoami()));
try (Scanner scan =
client.createScanner(tableName, secOps.getUserAuthorizations(client.whoami()))) {
int seen = 0;
Iterator<Entry<Key,Value>> iter = scan.iterator();
while (iter.hasNext()) {
Entry<Key,Value> entry = iter.next();
for (Entry<Key,Value> entry : scan) {
Key k = entry.getKey();
seen++;
if (!auths.contains(k.getColumnVisibilityData()) && !ambiguousAuths)
Expand Down Expand Up @@ -156,12 +152,6 @@ public void visit(State state, RandWalkEnv env, Properties props) throws Excepti
}

throw new AccumuloException("Unexpected exception!", re);
} finally {
if (scan != null) {
scan.close();
scan = null;
}

}

break;
Expand All @@ -183,20 +173,10 @@ public void visit(State state, RandWalkEnv env, Properties props) throws Excepti
m.put(new Text(), new Text(), new ColumnVisibility(s),
new Value("value".getBytes(UTF_8)));
}
BatchWriter writer = null;
try {
try {
writer = client.createBatchWriter(tableName,
new BatchWriterConfig().setMaxMemory(9000l).setMaxWriteThreads(1));
} catch (TableNotFoundException tnfe) {
if (tableExists)
throw new AccumuloException("Table didn't exist when it should have: " + tableName);
return;
}
boolean works = true;
try (BatchWriter writer = client.createBatchWriter(tableName,
new BatchWriterConfig().setMaxMemory(9000L).setMaxWriteThreads(1))) {
try {
writer.addMutation(m);
writer.close();
} catch (MutationsRejectedException mre) {
if (mre.getSecurityErrorCodes().size() == 1) {
// TabletServerBatchWriter will log the error automatically so make sure its the
Expand All @@ -212,14 +192,12 @@ public void visit(State state, RandWalkEnv env, Properties props) throws Excepti
throw new AccumuloException("Unexpected MutationsRejectedException in TableOp.WRITE",
mre);
}
if (works)
for (String s : WalkingSecurity.get(state, env).getAuthsArray())
WalkingSecurity.get(state, env).increaseAuthMap(s, 1);
} finally {
if (writer != null) {
writer.close();
writer = null;
}
for (String s : WalkingSecurity.get(state, env).getAuthsArray())
WalkingSecurity.get(state, env).increaseAuthMap(s, 1);
} catch (TableNotFoundException tnfe) {
if (tableExists)
throw new AccumuloException("Table didn't exist when it should have: " + tableName);
return;
}
break;
case BULK_IMPORT:
Expand All @@ -229,16 +207,16 @@ public void visit(State state, RandWalkEnv env, Properties props) throws Excepti
Key k = new Key(key, "", "", s);
keys.add(k);
}
Path dir = new Path("/tmp", "bulk_" + UUID.randomUUID().toString());
Path fail = new Path(dir.toString() + "_fail");
FileSystem fs = WalkingSecurity.get(state, env).getFs();
RFileWriter rFileWriter =
RFile.newWriter().to(dir + "/securityBulk.rf").withFileSystem(fs).build();
rFileWriter.startDefaultLocalityGroup();
Path dir = new Path("/tmp", "bulk_" + UUID.randomUUID());
Path fail = new Path(dir + "_fail");
fs.mkdirs(fail);
for (Key k : keys)
rFileWriter.append(k, new Value("Value".getBytes(UTF_8)));
rFileWriter.close();
try (RFileWriter rFileWriter =
RFile.newWriter().to(dir + "/securityBulk.rf").withFileSystem(fs).build()) {
rFileWriter.startDefaultLocalityGroup();
for (Key k : keys)
rFileWriter.append(k, new Value("Value".getBytes(UTF_8)));
}
try {
tableOps.importDirectory(dir.toString()).to(tableName).tableTime(true).load();
} catch (TableNotFoundException tnfe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ public String[] getAuthsArray() {
public boolean inAmbiguousZone(String userName, TablePermission tp) {
if (tp.equals(TablePermission.READ) || tp.equals(TablePermission.WRITE)) {
Long setTime = state.getLong("Tab-" + userName + '-' + tp.name() + '-' + "time");
if (setTime == null)
if (setTime == null) {
throw new RuntimeException("Tab-" + userName + '-' + tp.name() + '-' + "time is null");
if (System.currentTimeMillis() < (setTime + 1000))
return true;
}
return System.currentTimeMillis() < (setTime + 1000);
}
return false;
}
Expand All @@ -291,19 +291,14 @@ public String getLastKey() {
}

public void increaseAuthMap(String s, int increment) {
Integer curVal = getAuthsMap().get(s);
if (curVal == null) {
curVal = Integer.valueOf(0);
getAuthsMap().put(s, curVal);
}
curVal += increment;
getAuthsMap().merge(s, increment, Integer::sum);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was not doing anything. I changed the code so that it actually updates the values of the map.

}

public FileSystem getFs() {
FileSystem fs = null;
try {
fs = (FileSystem) state.get(filesystem);
} catch (RuntimeException re) {}
} catch (RuntimeException ignored) {}

if (fs == null) {
try {
Expand Down