[1/2] hbase git commit: HBASE-14548 Expand how table coprocessor jar and dependency path can be specified (Xiang Li)

2016-08-01 Thread apurtell
Repository: hbase
Updated Branches:
  refs/heads/0.98 27c583467 -> 6dfdc0d89


HBASE-14548 Expand how table coprocessor jar and dependency path can be 
specified (Xiang Li)

Amending-Author: Andrew Purtell 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f750acb7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f750acb7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f750acb7

Branch: refs/heads/0.98
Commit: f750acb751c5cc3b4a3292451c0504942b62bf39
Parents: 27c5834
Author: Jerry He 
Authored: Sat Jul 9 18:18:22 2016 -0700
Committer: Andrew Purtell 
Committed: Mon Aug 1 15:52:44 2016 -0700

--
 .../hbase/util/CoprocessorClassLoader.java  | 74 +---
 .../hbase/util/TestCoprocessorClassLoader.java  | 43 
 2 files changed, 93 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/f750acb7/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
index fb2a127..9b65807 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.util;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -39,6 +40,9 @@ import 
org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.io.IOUtils;
 
 import com.google.common.base.Preconditions;
@@ -155,7 +159,7 @@ public class CoprocessorClassLoader extends ClassLoaderBase 
{
 super(parent);
   }
 
-  private void init(Path path, String pathPrefix,
+  private void init(Path pathPattern, String pathPrefix,
   Configuration conf) throws IOException {
 // Copy the jar to the local filesystem
 String parentDirStr =
@@ -173,31 +177,53 @@ public class CoprocessorClassLoader extends 
ClassLoaderBase {
   }
 }
 
-FileSystem fs = path.getFileSystem(conf);
-File dst = new File(parentDirStr, "." + pathPrefix + "."
-  + path.getName() + "." + System.currentTimeMillis() + ".jar");
-fs.copyToLocalFile(path, new Path(dst.toString()));
-dst.deleteOnExit();
-
-addURL(dst.getCanonicalFile().toURI().toURL());
+FileSystem fs = pathPattern.getFileSystem(conf);
+Path pathPattern1 = fs.isDirectory(pathPattern) ?
+  new Path(pathPattern, "*.jar") : pathPattern;  // append "*.jar" if a 
directory is specified
+FileStatus[] fileStatuses = fs.globStatus(pathPattern1);  // return all 
files that match the pattern
+if (fileStatuses == null || fileStatuses.length == 0) {  // if no one 
matches
+  throw new FileNotFoundException(pathPattern1.toString());
+} else {
+  boolean validFileEncountered = false;
+  for (Path path : FileUtil.stat2Paths(fileStatuses)) {  // for each file 
that match the pattern
+if (fs.isFile(path)) {  // only process files, skip for directories
+  File dst = new File(parentDirStr, "." + pathPrefix + "."
++ path.getName() + "." + System.currentTimeMillis() + ".jar");
+  fs.copyToLocalFile(path, new Path(dst.toString()));
+  dst.deleteOnExit();
+
+  addURL(dst.getCanonicalFile().toURI().toURL());
+
+  JarFile jarFile = new JarFile(dst.toString());
+  try {
+Enumeration entries = jarFile.entries();  // get entries 
inside a jar file
+while (entries.hasMoreElements()) {
+  JarEntry entry = entries.nextElement();
+  Matcher m = libJarPattern.matcher(entry.getName());
+  if (m.matches()) {
+File file = new File(parentDirStr, "." + pathPrefix + "."
+  + path.getName() + "." + System.currentTimeMillis() + "." + 
m.group(1));
+FileOutputStream outStream = new FileOutputStream(file);
+try {
+  IOUtils.copyBytes(jarFile.getInputStream(entry),
+outStream, conf, true);
+} finally {
+  outStream.close();
+}
+file.deleteOnExit();
+

[05/50] [abbrv] hbase git commit: HBASE-14548 Expand how table coprocessor jar and dependency path can be specified (Xiang Li)

2016-07-11 Thread eclark
HBASE-14548 Expand how table coprocessor jar and dependency path can be 
specified (Xiang Li)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/63296978
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/63296978
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/63296978

Branch: refs/heads/HBASE-14850
Commit: 632969787aa9e9e1d73b83449b93e21f91110b73
Parents: 496fd98
Author: Jerry He 
Authored: Sat Jul 9 18:00:41 2016 -0700
Committer: Jerry He 
Committed: Sat Jul 9 18:01:49 2016 -0700

--
 .../hbase/util/CoprocessorClassLoader.java  | 72 +---
 .../hbase/util/TestCoprocessorClassLoader.java  | 43 
 src/main/asciidoc/_chapters/cp.adoc |  9 ++-
 3 files changed, 97 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/63296978/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
index 11016c3..c3635cb 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.util;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -38,6 +39,8 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.io.IOUtils;
 
@@ -142,7 +145,7 @@ public class CoprocessorClassLoader extends ClassLoaderBase 
{
 super(parent);
   }
 
-  private void init(Path path, String pathPrefix,
+  private void init(Path pathPattern, String pathPrefix,
   Configuration conf) throws IOException {
 // Copy the jar to the local filesystem
 String parentDirStr =
@@ -160,33 +163,50 @@ public class CoprocessorClassLoader extends 
ClassLoaderBase {
   }
 }
 
-FileSystem fs = path.getFileSystem(conf);
-File dst = new File(parentDirStr, "." + pathPrefix + "."
-  + path.getName() + "." + System.currentTimeMillis() + ".jar");
-fs.copyToLocalFile(path, new Path(dst.toString()));
-dst.deleteOnExit();
-
-addURL(dst.getCanonicalFile().toURI().toURL());
-
-JarFile jarFile = new JarFile(dst.toString());
-try {
-  Enumeration entries = jarFile.entries();
-  while (entries.hasMoreElements()) {
-JarEntry entry = entries.nextElement();
-Matcher m = libJarPattern.matcher(entry.getName());
-if (m.matches()) {
-  File file = new File(parentDirStr, "." + pathPrefix + "."
-+ path.getName() + "." + System.currentTimeMillis() + "." + 
m.group(1));
-  try (FileOutputStream outStream = new FileOutputStream(file)) {
-IOUtils.copyBytes(jarFile.getInputStream(entry),
-  outStream, conf, true);
+FileSystem fs = pathPattern.getFileSystem(conf);
+Path pathPattern1 = fs.isDirectory(pathPattern) ?
+  new Path(pathPattern, "*.jar") : pathPattern;  // append "*.jar" if a 
directory is specified
+FileStatus[] fileStatuses = fs.globStatus(pathPattern1);  // return all 
files that match the pattern
+if (fileStatuses == null || fileStatuses.length == 0) {  // if no one 
matches
+  throw new FileNotFoundException(pathPattern1.toString());
+} else {
+  boolean validFileEncountered = false;
+  for (Path path : FileUtil.stat2Paths(fileStatuses)) {  // for each file 
that match the pattern
+if (fs.isFile(path)) {  // only process files, skip for directories
+  File dst = new File(parentDirStr, "." + pathPrefix + "."
++ path.getName() + "." + System.currentTimeMillis() + ".jar");
+  fs.copyToLocalFile(path, new Path(dst.toString()));
+  dst.deleteOnExit();
+
+  addURL(dst.getCanonicalFile().toURI().toURL());
+
+  JarFile jarFile = new JarFile(dst.toString());
+  try {
+Enumeration entries = jarFile.entries();  // get entries 
inside a jar file
+while (entries.hasMoreElements()) {
+  JarEntry entry = entries.nextElement();
+  Matcher m = libJarPattern.matcher(entry.getName());
+  if (m.matches()) {
+File file = new 

hbase git commit: HBASE-14548 Expand how table coprocessor jar and dependency path can be specified (Xiang Li)

2016-07-09 Thread jerryjch
Repository: hbase
Updated Branches:
  refs/heads/branch-1 9563ab4ca -> fe915e10d


HBASE-14548 Expand how table coprocessor jar and dependency path can be 
specified (Xiang Li)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/fe915e10
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/fe915e10
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/fe915e10

Branch: refs/heads/branch-1
Commit: fe915e10d6f021357e53984742bcb36091306ea1
Parents: 9563ab4
Author: Jerry He 
Authored: Sat Jul 9 18:18:22 2016 -0700
Committer: Jerry He 
Committed: Sat Jul 9 18:18:22 2016 -0700

--
 .../hbase/util/CoprocessorClassLoader.java  | 71 +---
 .../hbase/util/TestCoprocessorClassLoader.java  | 43 
 2 files changed, 90 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/fe915e10/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
index 5f949d9..56fab75 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.util;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -39,6 +40,9 @@ import 
org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.io.IOUtils;
 
 import com.google.common.base.Preconditions;
@@ -155,7 +159,7 @@ public class CoprocessorClassLoader extends ClassLoaderBase 
{
 super(parent);
   }
 
-  private void init(Path path, String pathPrefix,
+  private void init(Path pathPattern, String pathPrefix,
   Configuration conf) throws IOException {
 // Copy the jar to the local filesystem
 String parentDirStr =
@@ -173,31 +177,50 @@ public class CoprocessorClassLoader extends 
ClassLoaderBase {
   }
 }
 
-FileSystem fs = path.getFileSystem(conf);
-File dst = new File(parentDirStr, "." + pathPrefix + "."
-  + path.getName() + "." + System.currentTimeMillis() + ".jar");
-fs.copyToLocalFile(path, new Path(dst.toString()));
-dst.deleteOnExit();
-
-addURL(dst.getCanonicalFile().toURI().toURL());
+FileSystem fs = pathPattern.getFileSystem(conf);
+Path pathPattern1 = fs.isDirectory(pathPattern) ?
+  new Path(pathPattern, "*.jar") : pathPattern;  // append "*.jar" if a 
directory is specified
+FileStatus[] fileStatuses = fs.globStatus(pathPattern1);  // return all 
files that match the pattern
+if (fileStatuses == null || fileStatuses.length == 0) {  // if no one 
matches
+  throw new FileNotFoundException(pathPattern1.toString());
+} else {
+  boolean validFileEncountered = false;
+  for (Path path : FileUtil.stat2Paths(fileStatuses)) {  // for each file 
that match the pattern
+if (fs.isFile(path)) {  // only process files, skip for directories
+  File dst = new File(parentDirStr, "." + pathPrefix + "."
++ path.getName() + "." + System.currentTimeMillis() + ".jar");
+  fs.copyToLocalFile(path, new Path(dst.toString()));
+  dst.deleteOnExit();
+
+  addURL(dst.getCanonicalFile().toURI().toURL());
+
+  JarFile jarFile = new JarFile(dst.toString());
+  try {
+Enumeration entries = jarFile.entries();  // get entries 
inside a jar file
+while (entries.hasMoreElements()) {
+  JarEntry entry = entries.nextElement();
+  Matcher m = libJarPattern.matcher(entry.getName());
+  if (m.matches()) {
+File file = new File(parentDirStr, "." + pathPrefix + "."
+  + path.getName() + "." + System.currentTimeMillis() + "." + 
m.group(1));
+try (FileOutputStream outStream = new FileOutputStream(file)) {
+  IOUtils.copyBytes(jarFile.getInputStream(entry),
+outStream, conf, true);
+}
+file.deleteOnExit();
+addURL(file.toURI().toURL());
+  }
+}
+  } finally {
+jarFile.close();
+  }
 
-

hbase git commit: HBASE-14548 Expand how table coprocessor jar and dependency path can be specified (Xiang Li)

2016-07-09 Thread jerryjch
Repository: hbase
Updated Branches:
  refs/heads/master 496fd9837 -> 632969787


HBASE-14548 Expand how table coprocessor jar and dependency path can be 
specified (Xiang Li)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/63296978
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/63296978
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/63296978

Branch: refs/heads/master
Commit: 632969787aa9e9e1d73b83449b93e21f91110b73
Parents: 496fd98
Author: Jerry He 
Authored: Sat Jul 9 18:00:41 2016 -0700
Committer: Jerry He 
Committed: Sat Jul 9 18:01:49 2016 -0700

--
 .../hbase/util/CoprocessorClassLoader.java  | 72 +---
 .../hbase/util/TestCoprocessorClassLoader.java  | 43 
 src/main/asciidoc/_chapters/cp.adoc |  9 ++-
 3 files changed, 97 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/63296978/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
--
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
index 11016c3..c3635cb 100644
--- 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
+++ 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.util;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -38,6 +39,8 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.io.IOUtils;
 
@@ -142,7 +145,7 @@ public class CoprocessorClassLoader extends ClassLoaderBase 
{
 super(parent);
   }
 
-  private void init(Path path, String pathPrefix,
+  private void init(Path pathPattern, String pathPrefix,
   Configuration conf) throws IOException {
 // Copy the jar to the local filesystem
 String parentDirStr =
@@ -160,33 +163,50 @@ public class CoprocessorClassLoader extends 
ClassLoaderBase {
   }
 }
 
-FileSystem fs = path.getFileSystem(conf);
-File dst = new File(parentDirStr, "." + pathPrefix + "."
-  + path.getName() + "." + System.currentTimeMillis() + ".jar");
-fs.copyToLocalFile(path, new Path(dst.toString()));
-dst.deleteOnExit();
-
-addURL(dst.getCanonicalFile().toURI().toURL());
-
-JarFile jarFile = new JarFile(dst.toString());
-try {
-  Enumeration entries = jarFile.entries();
-  while (entries.hasMoreElements()) {
-JarEntry entry = entries.nextElement();
-Matcher m = libJarPattern.matcher(entry.getName());
-if (m.matches()) {
-  File file = new File(parentDirStr, "." + pathPrefix + "."
-+ path.getName() + "." + System.currentTimeMillis() + "." + 
m.group(1));
-  try (FileOutputStream outStream = new FileOutputStream(file)) {
-IOUtils.copyBytes(jarFile.getInputStream(entry),
-  outStream, conf, true);
+FileSystem fs = pathPattern.getFileSystem(conf);
+Path pathPattern1 = fs.isDirectory(pathPattern) ?
+  new Path(pathPattern, "*.jar") : pathPattern;  // append "*.jar" if a 
directory is specified
+FileStatus[] fileStatuses = fs.globStatus(pathPattern1);  // return all 
files that match the pattern
+if (fileStatuses == null || fileStatuses.length == 0) {  // if no one 
matches
+  throw new FileNotFoundException(pathPattern1.toString());
+} else {
+  boolean validFileEncountered = false;
+  for (Path path : FileUtil.stat2Paths(fileStatuses)) {  // for each file 
that match the pattern
+if (fs.isFile(path)) {  // only process files, skip for directories
+  File dst = new File(parentDirStr, "." + pathPrefix + "."
++ path.getName() + "." + System.currentTimeMillis() + ".jar");
+  fs.copyToLocalFile(path, new Path(dst.toString()));
+  dst.deleteOnExit();
+
+  addURL(dst.getCanonicalFile().toURI().toURL());
+
+  JarFile jarFile = new JarFile(dst.toString());
+  try {
+Enumeration entries = jarFile.entries();  // get entries 
inside a jar file
+while (entries.hasMoreElements()) {
+  JarEntry entry = entries.nextElement();
+  Matcher m =