You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bh...@apache.org on 2014/03/27 22:35:43 UTC
[01/11] git commit: ACCUMULO-2524 Check for null args to
ProblemReport constructors
Repository: accumulo
Updated Branches:
refs/heads/1.4.5-SNAPSHOT 461910148 -> 1258b4e03
refs/heads/1.5.2-SNAPSHOT 4a05a17de -> 334f7a724
refs/heads/1.6.0-SNAPSHOT 3ce0bfda3 -> d3bd456e7
refs/heads/master 3c935b129 -> 4cfde769c
ACCUMULO-2524 Check for null args to ProblemReport constructors
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1258b4e0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1258b4e0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1258b4e0
Branch: refs/heads/1.4.5-SNAPSHOT
Commit: 1258b4e0352e99d70b34b1131a4cfa5f90afd6ff
Parents: 4619101
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:19:24 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:19:24 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1258b4e0/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 06959d0..bc8f8ac 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.Encoding;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -48,6 +49,7 @@ public class ProblemReport {
private long creationTime;
public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
@@ -74,6 +76,7 @@ public class ProblemReport {
}
private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
this.resource = resource;
[10/11] git commit: Merge branch '1.6.0-SNAPSHOT'
Posted by bh...@apache.org.
Merge branch '1.6.0-SNAPSHOT'
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/367a4d02
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/367a4d02
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/367a4d02
Branch: refs/heads/master
Commit: 367a4d02ddf34ee071ca32834c4ffd8e6554a1e6
Parents: 3c935b1 d3bd456
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:22:01 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:22:01 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
[05/11] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/334f7a72
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/334f7a72
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/334f7a72
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 334f7a724c77616e307f2e3090e30074c5ede5b9
Parents: 4a05a17 1258b4e
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:21:00 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:21:00 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/334f7a72/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 6b32117,0000000..0c7e2d1
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@@ -1,221 -1,0 +1,224 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.problems;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.security.SecurityConstants;
+import org.apache.accumulo.server.util.MetadataTable;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.hadoop.io.Text;
+
+public class ProblemReport {
+ private String tableName;
+ private ProblemType problemType;
+ private String resource;
+ private String exception;
+ private String server;
+ private long creationTime;
+
+ public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+
+ this.problemType = problemType;
+ this.resource = resource;
+
+ if (e != null) {
+ this.exception = e.getMessage();
+ }
+
+ if (server == null) {
+ try {
+ server = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+
+ }
+ }
+
+ this.server = server;
+ this.creationTime = System.currentTimeMillis();
+ }
+
+ public ProblemReport(String table, ProblemType problemType, String resource, Throwable e) {
+ this(table, problemType, resource, null, e);
+ }
+
+ private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+ this.problemType = problemType;
+ this.resource = resource;
+
+ decode(enc);
+ }
+
+ private byte[] encode() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+
+ dos.writeLong(creationTime);
+
+ dos.writeBoolean(server != null);
+ if (server != null) {
+ dos.writeUTF(server);
+ }
+
+ dos.writeBoolean(exception != null);
+ if (exception != null) {
+ dos.writeUTF(exception);
+ }
+
+ dos.close();
+ baos.close();
+
+ return baos.toByteArray();
+ }
+
+ private void decode(byte enc[]) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(enc);
+ DataInputStream dis = new DataInputStream(bais);
+
+ creationTime = dis.readLong();
+
+ if (dis.readBoolean()) {
+ server = dis.readUTF();
+ } else {
+ server = null;
+ }
+
+ if (dis.readBoolean()) {
+ exception = dis.readUTF();
+ } else {
+ exception = null;
+ }
+ }
+
+ void removeFromMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.putDelete(new Text(problemType.name()), new Text(resource));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void saveToMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.put(new Text(problemType.name()), new Text(resource), new Value(encode()));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void removeFromZooKeeper() throws Exception {
+ String zpath = getZPath();
+ ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP);
+ }
+
+ void saveToZooKeeper() throws Exception {
+ ZooReaderWriter.getInstance().putPersistentData(getZPath(), encode(), NodeExistsPolicy.OVERWRITE);
+ }
+
+ private String getZPath() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(getTableName());
+ dos.writeUTF(getProblemType().name());
+ dos.writeUTF(getResource());
+ dos.close();
+ baos.close();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + Encoding.encodeAsBase64FileName(new Text(baos.toByteArray()));
+ return zpath;
+ }
+
+ static ProblemReport decodeZooKeeperEntry(String node) throws Exception {
+ byte bytes[] = Encoding.decodeBase64FileName(node);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+
+ String tableName = dis.readUTF();
+ String problemType = dis.readUTF();
+ String resource = dis.readUTF();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + node;
+ byte[] enc = ZooReaderWriter.getInstance().getData(zpath, null);
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, enc);
+
+ }
+
+ public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException {
+ String tableName = entry.getKey().getRow().toString().substring("~err_".length());
+ String problemType = entry.getKey().getColumnFamily().toString();
+ String resource = entry.getKey().getColumnQualifier().toString();
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, entry.getValue().get());
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public ProblemType getProblemType() {
+ return problemType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getException() {
+ return exception;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ public long getTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ return tableName.hashCode() + problemType.hashCode() + resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ProblemReport) {
+ ProblemReport opr = (ProblemReport) o;
+ return tableName.equals(opr.tableName) && problemType.equals(opr.problemType) && resource.equals(opr.resource);
+ }
+ return false;
+ }
+}
[09/11] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d3bd456e
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d3bd456e
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d3bd456e
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: d3bd456e7e397f1a658f794b9d72f5eec50cf607
Parents: 3ce0bfd 334f7a7
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:21:45 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:21:45 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d3bd456e/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --cc server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index fec4e55,0000000..decc995
mode 100644,000000..100644
--- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@@ -1,221 -1,0 +1,224 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.problems;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.security.SystemCredentials;
+import org.apache.accumulo.server.util.MetadataTableUtil;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.hadoop.io.Text;
+
+public class ProblemReport {
+ private String tableName;
+ private ProblemType problemType;
+ private String resource;
+ private String exception;
+ private String server;
+ private long creationTime;
+
+ public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+
+ this.problemType = problemType;
+ this.resource = resource;
+
+ if (e != null) {
+ this.exception = e.getMessage();
+ }
+
+ if (server == null) {
+ try {
+ server = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+
+ }
+ }
+
+ this.server = server;
+ this.creationTime = System.currentTimeMillis();
+ }
+
+ public ProblemReport(String table, ProblemType problemType, String resource, Throwable e) {
+ this(table, problemType, resource, null, e);
+ }
+
+ private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+ this.problemType = problemType;
+ this.resource = resource;
+
+ decode(enc);
+ }
+
+ private byte[] encode() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+
+ dos.writeLong(creationTime);
+
+ dos.writeBoolean(server != null);
+ if (server != null) {
+ dos.writeUTF(server);
+ }
+
+ dos.writeBoolean(exception != null);
+ if (exception != null) {
+ dos.writeUTF(exception);
+ }
+
+ dos.close();
+ baos.close();
+
+ return baos.toByteArray();
+ }
+
+ private void decode(byte enc[]) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(enc);
+ DataInputStream dis = new DataInputStream(bais);
+
+ creationTime = dis.readLong();
+
+ if (dis.readBoolean()) {
+ server = dis.readUTF();
+ } else {
+ server = null;
+ }
+
+ if (dis.readBoolean()) {
+ exception = dis.readUTF();
+ } else {
+ exception = null;
+ }
+ }
+
+ void removeFromMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.putDelete(new Text(problemType.name()), new Text(resource));
+ MetadataTableUtil.getMetadataTable(SystemCredentials.get()).update(m);
+ }
+
+ void saveToMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.put(new Text(problemType.name()), new Text(resource), new Value(encode()));
+ MetadataTableUtil.getMetadataTable(SystemCredentials.get()).update(m);
+ }
+
+ void removeFromZooKeeper() throws Exception {
+ String zpath = getZPath();
+ ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP);
+ }
+
+ void saveToZooKeeper() throws Exception {
+ ZooReaderWriter.getInstance().putPersistentData(getZPath(), encode(), NodeExistsPolicy.OVERWRITE);
+ }
+
+ private String getZPath() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(getTableName());
+ dos.writeUTF(getProblemType().name());
+ dos.writeUTF(getResource());
+ dos.close();
+ baos.close();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + Encoding.encodeAsBase64FileName(new Text(baos.toByteArray()));
+ return zpath;
+ }
+
+ static ProblemReport decodeZooKeeperEntry(String node) throws Exception {
+ byte bytes[] = Encoding.decodeBase64FileName(node);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+
+ String tableName = dis.readUTF();
+ String problemType = dis.readUTF();
+ String resource = dis.readUTF();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + node;
+ byte[] enc = ZooReaderWriter.getInstance().getData(zpath, null);
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, enc);
+
+ }
+
+ public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException {
+ String tableName = entry.getKey().getRow().toString().substring("~err_".length());
+ String problemType = entry.getKey().getColumnFamily().toString();
+ String resource = entry.getKey().getColumnQualifier().toString();
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, entry.getValue().get());
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public ProblemType getProblemType() {
+ return problemType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getException() {
+ return exception;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ public long getTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ return tableName.hashCode() + problemType.hashCode() + resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ProblemReport) {
+ ProblemReport opr = (ProblemReport) o;
+ return tableName.equals(opr.tableName) && problemType.equals(opr.problemType) && resource.equals(opr.resource);
+ }
+ return false;
+ }
+}
[11/11] git commit: ACCUMULO-2524 Update ProblemReport to use
Preconditions over ArgumentChecker
Posted by bh...@apache.org.
ACCUMULO-2524 Update ProblemReport to use Preconditions over ArgumentChecker
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4cfde769
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4cfde769
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4cfde769
Branch: refs/heads/master
Commit: 4cfde769c0d1d12de40993c3b25776a64bcf00a8
Parents: 367a4d0
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:35:07 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:35:07 2014 -0400
----------------------------------------------------------------------
.../apache/accumulo/server/problems/ProblemReport.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cfde769/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index decc995..d0aef3d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.problems;
+import static com.google.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
@@ -29,7 +30,6 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.Encoding;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -49,7 +49,9 @@ public class ProblemReport {
private long creationTime;
public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
- ArgumentChecker.notNull(table, problemType, resource);
+ checkNotNull(table, "table is null");
+ checkNotNull(problemType, "problemType is null");
+ checkNotNull(resource, "resource is null");
this.tableName = table;
this.problemType = problemType;
@@ -76,7 +78,9 @@ public class ProblemReport {
}
private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
- ArgumentChecker.notNull(table, problemType, resource);
+ checkNotNull(table, "table is null");
+ checkNotNull(problemType, "problemType is null");
+ checkNotNull(resource, "resource is null");
this.tableName = table;
this.problemType = problemType;
this.resource = resource;
[08/11] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d3bd456e
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d3bd456e
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d3bd456e
Branch: refs/heads/master
Commit: d3bd456e7e397f1a658f794b9d72f5eec50cf607
Parents: 3ce0bfd 334f7a7
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:21:45 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:21:45 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d3bd456e/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --cc server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index fec4e55,0000000..decc995
mode 100644,000000..100644
--- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@@ -1,221 -1,0 +1,224 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.problems;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.security.SystemCredentials;
+import org.apache.accumulo.server.util.MetadataTableUtil;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.hadoop.io.Text;
+
+public class ProblemReport {
+ private String tableName;
+ private ProblemType problemType;
+ private String resource;
+ private String exception;
+ private String server;
+ private long creationTime;
+
+ public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+
+ this.problemType = problemType;
+ this.resource = resource;
+
+ if (e != null) {
+ this.exception = e.getMessage();
+ }
+
+ if (server == null) {
+ try {
+ server = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+
+ }
+ }
+
+ this.server = server;
+ this.creationTime = System.currentTimeMillis();
+ }
+
+ public ProblemReport(String table, ProblemType problemType, String resource, Throwable e) {
+ this(table, problemType, resource, null, e);
+ }
+
+ private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+ this.problemType = problemType;
+ this.resource = resource;
+
+ decode(enc);
+ }
+
+ private byte[] encode() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+
+ dos.writeLong(creationTime);
+
+ dos.writeBoolean(server != null);
+ if (server != null) {
+ dos.writeUTF(server);
+ }
+
+ dos.writeBoolean(exception != null);
+ if (exception != null) {
+ dos.writeUTF(exception);
+ }
+
+ dos.close();
+ baos.close();
+
+ return baos.toByteArray();
+ }
+
+ private void decode(byte enc[]) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(enc);
+ DataInputStream dis = new DataInputStream(bais);
+
+ creationTime = dis.readLong();
+
+ if (dis.readBoolean()) {
+ server = dis.readUTF();
+ } else {
+ server = null;
+ }
+
+ if (dis.readBoolean()) {
+ exception = dis.readUTF();
+ } else {
+ exception = null;
+ }
+ }
+
+ void removeFromMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.putDelete(new Text(problemType.name()), new Text(resource));
+ MetadataTableUtil.getMetadataTable(SystemCredentials.get()).update(m);
+ }
+
+ void saveToMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.put(new Text(problemType.name()), new Text(resource), new Value(encode()));
+ MetadataTableUtil.getMetadataTable(SystemCredentials.get()).update(m);
+ }
+
+ void removeFromZooKeeper() throws Exception {
+ String zpath = getZPath();
+ ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP);
+ }
+
+ void saveToZooKeeper() throws Exception {
+ ZooReaderWriter.getInstance().putPersistentData(getZPath(), encode(), NodeExistsPolicy.OVERWRITE);
+ }
+
+ private String getZPath() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(getTableName());
+ dos.writeUTF(getProblemType().name());
+ dos.writeUTF(getResource());
+ dos.close();
+ baos.close();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + Encoding.encodeAsBase64FileName(new Text(baos.toByteArray()));
+ return zpath;
+ }
+
+ static ProblemReport decodeZooKeeperEntry(String node) throws Exception {
+ byte bytes[] = Encoding.decodeBase64FileName(node);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+
+ String tableName = dis.readUTF();
+ String problemType = dis.readUTF();
+ String resource = dis.readUTF();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + node;
+ byte[] enc = ZooReaderWriter.getInstance().getData(zpath, null);
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, enc);
+
+ }
+
+ public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException {
+ String tableName = entry.getKey().getRow().toString().substring("~err_".length());
+ String problemType = entry.getKey().getColumnFamily().toString();
+ String resource = entry.getKey().getColumnQualifier().toString();
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, entry.getValue().get());
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public ProblemType getProblemType() {
+ return problemType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getException() {
+ return exception;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ public long getTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ return tableName.hashCode() + problemType.hashCode() + resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ProblemReport) {
+ ProblemReport opr = (ProblemReport) o;
+ return tableName.equals(opr.tableName) && problemType.equals(opr.problemType) && resource.equals(opr.resource);
+ }
+ return false;
+ }
+}
[07/11] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/334f7a72
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/334f7a72
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/334f7a72
Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 334f7a724c77616e307f2e3090e30074c5ede5b9
Parents: 4a05a17 1258b4e
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:21:00 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:21:00 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/334f7a72/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 6b32117,0000000..0c7e2d1
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@@ -1,221 -1,0 +1,224 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.problems;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.security.SecurityConstants;
+import org.apache.accumulo.server.util.MetadataTable;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.hadoop.io.Text;
+
+public class ProblemReport {
+ private String tableName;
+ private ProblemType problemType;
+ private String resource;
+ private String exception;
+ private String server;
+ private long creationTime;
+
+ public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+
+ this.problemType = problemType;
+ this.resource = resource;
+
+ if (e != null) {
+ this.exception = e.getMessage();
+ }
+
+ if (server == null) {
+ try {
+ server = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+
+ }
+ }
+
+ this.server = server;
+ this.creationTime = System.currentTimeMillis();
+ }
+
+ public ProblemReport(String table, ProblemType problemType, String resource, Throwable e) {
+ this(table, problemType, resource, null, e);
+ }
+
+ private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+ this.problemType = problemType;
+ this.resource = resource;
+
+ decode(enc);
+ }
+
+ private byte[] encode() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+
+ dos.writeLong(creationTime);
+
+ dos.writeBoolean(server != null);
+ if (server != null) {
+ dos.writeUTF(server);
+ }
+
+ dos.writeBoolean(exception != null);
+ if (exception != null) {
+ dos.writeUTF(exception);
+ }
+
+ dos.close();
+ baos.close();
+
+ return baos.toByteArray();
+ }
+
+ private void decode(byte enc[]) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(enc);
+ DataInputStream dis = new DataInputStream(bais);
+
+ creationTime = dis.readLong();
+
+ if (dis.readBoolean()) {
+ server = dis.readUTF();
+ } else {
+ server = null;
+ }
+
+ if (dis.readBoolean()) {
+ exception = dis.readUTF();
+ } else {
+ exception = null;
+ }
+ }
+
+ void removeFromMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.putDelete(new Text(problemType.name()), new Text(resource));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void saveToMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.put(new Text(problemType.name()), new Text(resource), new Value(encode()));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void removeFromZooKeeper() throws Exception {
+ String zpath = getZPath();
+ ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP);
+ }
+
+ void saveToZooKeeper() throws Exception {
+ ZooReaderWriter.getInstance().putPersistentData(getZPath(), encode(), NodeExistsPolicy.OVERWRITE);
+ }
+
+ private String getZPath() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(getTableName());
+ dos.writeUTF(getProblemType().name());
+ dos.writeUTF(getResource());
+ dos.close();
+ baos.close();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + Encoding.encodeAsBase64FileName(new Text(baos.toByteArray()));
+ return zpath;
+ }
+
+ static ProblemReport decodeZooKeeperEntry(String node) throws Exception {
+ byte bytes[] = Encoding.decodeBase64FileName(node);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+
+ String tableName = dis.readUTF();
+ String problemType = dis.readUTF();
+ String resource = dis.readUTF();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + node;
+ byte[] enc = ZooReaderWriter.getInstance().getData(zpath, null);
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, enc);
+
+ }
+
+ public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException {
+ String tableName = entry.getKey().getRow().toString().substring("~err_".length());
+ String problemType = entry.getKey().getColumnFamily().toString();
+ String resource = entry.getKey().getColumnQualifier().toString();
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, entry.getValue().get());
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public ProblemType getProblemType() {
+ return problemType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getException() {
+ return exception;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ public long getTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ return tableName.hashCode() + problemType.hashCode() + resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ProblemReport) {
+ ProblemReport opr = (ProblemReport) o;
+ return tableName.equals(opr.tableName) && problemType.equals(opr.problemType) && resource.equals(opr.resource);
+ }
+ return false;
+ }
+}
[06/11] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/334f7a72
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/334f7a72
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/334f7a72
Branch: refs/heads/master
Commit: 334f7a724c77616e307f2e3090e30074c5ede5b9
Parents: 4a05a17 1258b4e
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:21:00 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:21:00 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/334f7a72/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 6b32117,0000000..0c7e2d1
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@@ -1,221 -1,0 +1,224 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.problems;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.security.SecurityConstants;
+import org.apache.accumulo.server.util.MetadataTable;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.hadoop.io.Text;
+
+public class ProblemReport {
+ private String tableName;
+ private ProblemType problemType;
+ private String resource;
+ private String exception;
+ private String server;
+ private long creationTime;
+
+ public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+
+ this.problemType = problemType;
+ this.resource = resource;
+
+ if (e != null) {
+ this.exception = e.getMessage();
+ }
+
+ if (server == null) {
+ try {
+ server = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e1) {
+
+ }
+ }
+
+ this.server = server;
+ this.creationTime = System.currentTimeMillis();
+ }
+
+ public ProblemReport(String table, ProblemType problemType, String resource, Throwable e) {
+ this(table, problemType, resource, null, e);
+ }
+
+ private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
++ ArgumentChecker.notNull(table, problemType, resource);
+ this.tableName = table;
+ this.problemType = problemType;
+ this.resource = resource;
+
+ decode(enc);
+ }
+
+ private byte[] encode() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+
+ dos.writeLong(creationTime);
+
+ dos.writeBoolean(server != null);
+ if (server != null) {
+ dos.writeUTF(server);
+ }
+
+ dos.writeBoolean(exception != null);
+ if (exception != null) {
+ dos.writeUTF(exception);
+ }
+
+ dos.close();
+ baos.close();
+
+ return baos.toByteArray();
+ }
+
+ private void decode(byte enc[]) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(enc);
+ DataInputStream dis = new DataInputStream(bais);
+
+ creationTime = dis.readLong();
+
+ if (dis.readBoolean()) {
+ server = dis.readUTF();
+ } else {
+ server = null;
+ }
+
+ if (dis.readBoolean()) {
+ exception = dis.readUTF();
+ } else {
+ exception = null;
+ }
+ }
+
+ void removeFromMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.putDelete(new Text(problemType.name()), new Text(resource));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void saveToMetadataTable() throws Exception {
+ Mutation m = new Mutation(new Text("~err_" + tableName));
+ m.put(new Text(problemType.name()), new Text(resource), new Value(encode()));
+ MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials()).update(m);
+ }
+
+ void removeFromZooKeeper() throws Exception {
+ String zpath = getZPath();
+ ZooReaderWriter.getInstance().recursiveDelete(zpath, NodeMissingPolicy.SKIP);
+ }
+
+ void saveToZooKeeper() throws Exception {
+ ZooReaderWriter.getInstance().putPersistentData(getZPath(), encode(), NodeExistsPolicy.OVERWRITE);
+ }
+
+ private String getZPath() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(getTableName());
+ dos.writeUTF(getProblemType().name());
+ dos.writeUTF(getResource());
+ dos.close();
+ baos.close();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + Encoding.encodeAsBase64FileName(new Text(baos.toByteArray()));
+ return zpath;
+ }
+
+ static ProblemReport decodeZooKeeperEntry(String node) throws Exception {
+ byte bytes[] = Encoding.decodeBase64FileName(node);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+
+ String tableName = dis.readUTF();
+ String problemType = dis.readUTF();
+ String resource = dis.readUTF();
+
+ String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZPROBLEMS + "/" + node;
+ byte[] enc = ZooReaderWriter.getInstance().getData(zpath, null);
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, enc);
+
+ }
+
+ public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException {
+ String tableName = entry.getKey().getRow().toString().substring("~err_".length());
+ String problemType = entry.getKey().getColumnFamily().toString();
+ String resource = entry.getKey().getColumnQualifier().toString();
+
+ return new ProblemReport(tableName, ProblemType.valueOf(problemType), resource, entry.getValue().get());
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public ProblemType getProblemType() {
+ return problemType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getException() {
+ return exception;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ public long getTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ return tableName.hashCode() + problemType.hashCode() + resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ProblemReport) {
+ ProblemReport opr = (ProblemReport) o;
+ return tableName.equals(opr.tableName) && problemType.equals(opr.problemType) && resource.equals(opr.resource);
+ }
+ return false;
+ }
+}
[04/11] git commit: ACCUMULO-2524 Check for null args to
ProblemReport constructors
Posted by bh...@apache.org.
ACCUMULO-2524 Check for null args to ProblemReport constructors
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1258b4e0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1258b4e0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1258b4e0
Branch: refs/heads/master
Commit: 1258b4e0352e99d70b34b1131a4cfa5f90afd6ff
Parents: 4619101
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:19:24 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:19:24 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1258b4e0/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 06959d0..bc8f8ac 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.Encoding;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -48,6 +49,7 @@ public class ProblemReport {
private long creationTime;
public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
@@ -74,6 +76,7 @@ public class ProblemReport {
}
private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
this.resource = resource;
[03/11] git commit: ACCUMULO-2524 Check for null args to
ProblemReport constructors
Posted by bh...@apache.org.
ACCUMULO-2524 Check for null args to ProblemReport constructors
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1258b4e0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1258b4e0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1258b4e0
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 1258b4e0352e99d70b34b1131a4cfa5f90afd6ff
Parents: 4619101
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:19:24 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:19:24 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1258b4e0/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 06959d0..bc8f8ac 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.Encoding;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -48,6 +49,7 @@ public class ProblemReport {
private long creationTime;
public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
@@ -74,6 +76,7 @@ public class ProblemReport {
}
private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
this.resource = resource;
[02/11] git commit: ACCUMULO-2524 Check for null args to
ProblemReport constructors
Posted by bh...@apache.org.
ACCUMULO-2524 Check for null args to ProblemReport constructors
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1258b4e0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1258b4e0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1258b4e0
Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 1258b4e0352e99d70b34b1131a4cfa5f90afd6ff
Parents: 4619101
Author: Bill Havanki <bh...@cloudera.com>
Authored: Thu Mar 27 17:19:24 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Thu Mar 27 17:19:24 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/problems/ProblemReport.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1258b4e0/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
index 06959d0..bc8f8ac 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.Encoding;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -48,6 +49,7 @@ public class ProblemReport {
private long creationTime;
public ProblemReport(String table, ProblemType problemType, String resource, String server, Throwable e) {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
@@ -74,6 +76,7 @@ public class ProblemReport {
}
private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException {
+ ArgumentChecker.notNull(table, problemType, resource);
this.tableName = table;
this.problemType = problemType;
this.resource = resource;