import com.datastax.driver.core.Statement;
public class History {
- public final UUID id;
- public final String action;
- public final String memo;
- public final String reconstruct;
- public final String subject;
- public final String target;
- public final String user;
- public final int yr_mon;
-
- public History(UUID id, String action, String memo, String subject, String target, String user, int yr_mon) {
- this.id = id;
- this.action = action;
- this.memo = memo;
- this.reconstruct = null;
- this.subject = subject;
- this.target = target;
- this.user = user;
- this.yr_mon = yr_mon;
- }
-
- public History(UUID id, String action, String memo, String reconstruct, String subject, String target, String user, int yr_mon) {
- this.id = id;
- this.action = action;
- this.memo = memo;
- this.reconstruct = reconstruct;
- this.subject = subject;
- this.target = target;
- this.user = user;
- this.yr_mon = yr_mon;
- }
+ public final UUID id;
+ public final String action;
+ public final String memo;
+ public final String reconstruct;
+ public final String subject;
+ public final String target;
+ public final String user;
+ public final int yr_mon;
+
+ public History(UUID id, String action, String memo, String subject, String target, String user, int yr_mon) {
+ this.id = id;
+ this.action = action;
+ this.memo = memo;
+ this.reconstruct = null;
+ this.subject = subject;
+ this.target = target;
+ this.user = user;
+ this.yr_mon = yr_mon;
+ }
+
+ public History(UUID id, String action, String memo, String reconstruct, String subject, String target, String user, int yr_mon) {
+ this.id = id;
+ this.action = action;
+ this.memo = memo;
+ this.reconstruct = reconstruct;
+ this.subject = subject;
+ this.target = target;
+ this.user = user;
+ this.yr_mon = yr_mon;
+ }
- public static void load(Trans trans, Session session, Creator<History> creator, Loader<History> loader) {
+ public static void load(Trans trans, Session session, Creator<History> creator, Loader<History> loader) {
trans.info().log( "query: " + creator.select() );
TimeTaken tt = trans.start("Read History", Env.REMOTE);
ResultSet results;
- try {
- Statement stmt = new SimpleStatement( creator.select() ).setReadTimeoutMillis(240000);
- results = session.execute(stmt);
+ try {
+ Statement stmt = new SimpleStatement( creator.select() ).setReadTimeoutMillis(240000);
+ results = session.execute(stmt);
} finally {
- tt.done();
+ tt.done();
}
- int count = 0;
+ int count = 0;
try {
- Iterator<Row> iter = results.iterator();
- Row row;
- tt = trans.start("Load History", Env.SUB);
- try {
- while(iter.hasNext()) {
- ++count;
- row = iter.next();
- loader.exec(creator.create(row));
- }
- } finally {
- tt.done();
- }
+ Iterator<Row> iter = results.iterator();
+ Row row;
+ tt = trans.start("Load History", Env.SUB);
+ try {
+ while(iter.hasNext()) {
+ ++count;
+ row = iter.next();
+ loader.exec(creator.create(row));
+ }
+ } finally {
+ tt.done();
+ }
} finally {
- trans.info().log("Found",count,"histories");
+ trans.info().log("Found",count,"histories");
}
- }
-
- public String toString() {
- return String.format("%s %d %s, %s, %s, %s, %s",
- id.toString(),
- yr_mon,
- user,
- target,
- action,
- subject,
- memo);
- }
+ }
+
+ public String toString() {
+ return String.format("%s %d %s, %s, %s, %s, %s",
+ id.toString(),
+ yr_mon,
+ user,
+ target,
+ action,
+ subject,
+ memo);
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return id.hashCode();
- }
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- return id.equals(obj);
- }
-
- public static Creator<History> sansConstruct = new Creator<History> () {
- @Override
- public History create(Row row) {
- return new History(
- row.getUUID(0),
- row.getString(1),
- row.getString(2),
- row.getString(3),
- row.getString(4),
- row.getString(5),
- row.getInt(6));
- }
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ return id.equals(obj);
+ }
+
+ public static Creator<History> sansConstruct = new Creator<History> () {
+ @Override
+ public History create(Row row) {
+ return new History(
+ row.getUUID(0),
+ row.getString(1),
+ row.getString(2),
+ row.getString(3),
+ row.getString(4),
+ row.getString(5),
+ row.getInt(6));
+ }
- @Override
- public String select() {
- return "SELECT id, action, memo, subject, target, user, yr_mon from authz.history LIMIT 10000000 ";
- }
- };
+ @Override
+ public String select() {
+ return "SELECT id, action, memo, subject, target, user, yr_mon from authz.history LIMIT 10000000 ";
+ }
+ };
- public static Creator<History> avecConstruct = new Creator<History> () {
- private final StringBuilder sb = new StringBuilder();
-
- @Override
- public History create(Row row) {
- ByteBuffer bb = row.getBytes(3);
- sb.setLength(0);
-
- if(bb!=null && bb.hasRemaining()) {
- sb.append("0x");
- while(bb.hasRemaining()) {
- sb.append(String.format("%02x",bb.get()));
- }
- bb.flip();
- }
- return new History(
- row.getUUID(0),
- row.getString(1),
- row.getString(2),
- sb.toString(),
- row.getString(4),
- row.getString(5),
- row.getString(6),
- row.getInt(7));
- }
+ public static Creator<History> avecConstruct = new Creator<History> () {
+ private final StringBuilder sb = new StringBuilder();
+
+ @Override
+ public History create(Row row) {
+ ByteBuffer bb = row.getBytes(3);
+ sb.setLength(0);
+
+ if(bb!=null && bb.hasRemaining()) {
+ sb.append("0x");
+ while(bb.hasRemaining()) {
+ sb.append(String.format("%02x",bb.get()));
+ }
+ bb.flip();
+ }
+ return new History(
+ row.getUUID(0),
+ row.getString(1),
+ row.getString(2),
+ sb.toString(),
+ row.getString(4),
+ row.getString(5),
+ row.getString(6),
+ row.getInt(7));
+ }
- @Override
- public String select() {
- return "SELECT id, action, memo, reconstruct, subject, target, user, yr_mon from authz.history LIMIT 10000000 ";
- }
- };
+ @Override
+ public String select() {
+ return "SELECT id, action, memo, reconstruct, subject, target, user, yr_mon from authz.history LIMIT 10000000 ";
+ }
+ };
}
\ No newline at end of file