Skip to content

Commit 9c1e25d

Browse files
committed
Adding changes like logging and conventions and license
1 parent 2aa6d65 commit 9c1e25d

File tree

9 files changed

+185
-86
lines changed

9 files changed

+185
-86
lines changed

beam/pom.xml

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more
3+
~ contributor license agreements. See the NOTICE file distributed with ~
4+
this work for additional information regarding copyright ownership. ~ The
5+
ASF licenses this file to You under the Apache License, Version 2.0 ~ (the
6+
"License"); you may not use this file except in compliance with ~ the License.
7+
You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
8+
~ ~ Unless required by applicable law or agreed to in writing, software ~
9+
distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT
10+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the
11+
License for the specific language governing permissions and ~ limitations
12+
under the License. -->
13+
114
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
215
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
316
<modelVersion>4.0.0</modelVersion>
@@ -14,17 +27,22 @@
1427

1528
<groupId>org.apache.zeppelin</groupId>
1629
<artifactId>zeppelin-beam</artifactId>
30+
<packaging>jar</packaging>
1731
<version>0.7.0-SNAPSHOT</version>
32+
<name>Zeppelin: Beam interpreter</name>
1833

19-
34+
<properties>
35+
<beam.hadoop.version>2.3.0</beam.hadoop.version>
36+
<beam.spark.version>1.4.1</beam.spark.version>
37+
<beam.beam.version>0.1.0-incubating</beam.beam.version>
38+
</properties>
2039

2140
<dependencies>
2241

23-
2442
<dependency>
2543
<groupId>org.apache.spark</groupId>
2644
<artifactId>spark-core_2.10</artifactId>
27-
<version>1.4.1</version>
45+
<version>${beam.spark.version}</version>
2846
<exclusions>
2947
<exclusion>
3048
<artifactId>slf4j-log4j12</artifactId>
@@ -48,16 +66,17 @@
4866
</exclusion>
4967
</exclusions>
5068
</dependency>
69+
5170
<dependency>
5271
<groupId>org.apache.spark</groupId>
5372
<artifactId>spark-streaming_2.10</artifactId>
54-
<version>1.4.1</version>
73+
<version>${beam.spark.version}</version>
5574
</dependency>
5675

5776
<dependency>
5877
<groupId>org.apache.hadoop</groupId>
5978
<artifactId>hadoop-mapreduce-client-core</artifactId>
60-
<version>2.3.0</version>
79+
<version>${beam.hadoop.version}</version>
6180
<exclusions>
6281
<exclusion>
6382
<artifactId>slf4j-log4j12</artifactId>
@@ -69,7 +88,7 @@
6988
<dependency>
7089
<groupId>org.apache.hadoop</groupId>
7190
<artifactId>hadoop-common</artifactId>
72-
<version>2.3.0</version>
91+
<version>${beam.hadoop.version}</version>
7392
<exclusions>
7493
<exclusion>
7594
<artifactId>slf4j-log4j12</artifactId>
@@ -81,95 +100,86 @@
81100
<dependency>
82101
<groupId>org.apache.hadoop</groupId>
83102
<artifactId>hadoop-hdfs</artifactId>
84-
<version>2.3.0</version>
103+
<version>${beam.hadoop.version}</version>
85104
</dependency>
105+
86106
<dependency>
87107
<groupId>org.apache.hadoop</groupId>
88108
<artifactId>hadoop-client</artifactId>
89-
<version>2.3.0</version>
109+
<version>${beam.hadoop.version}</version>
90110
<exclusions>
91111
<exclusion>
92112
<artifactId>slf4j-log4j12</artifactId>
93113
<groupId>org.slf4j</groupId>
94114
</exclusion>
95115
</exclusions>
96116
</dependency>
117+
97118
<dependency>
98119
<groupId>org.apache.hadoop</groupId>
99120
<artifactId>hadoop-annotations</artifactId>
100-
<version>2.3.0</version>
121+
<version>${beam.hadoop.version}</version>
101122
</dependency>
123+
102124
<dependency>
103125
<groupId>org.apache.hadoop</groupId>
104126
<artifactId>hadoop-yarn-common</artifactId>
105-
<version>2.3.0</version>
127+
<version>${beam.hadoop.version}</version>
106128
</dependency>
129+
107130
<dependency>
108131
<groupId>org.apache.hadoop</groupId>
109132
<artifactId>hadoop-mapreduce-client-common</artifactId>
110-
<version>2.3.0</version>
133+
<version>${beam.hadoop.version}</version>
111134
<exclusions>
112135
<exclusion>
113136
<artifactId>slf4j-log4j12</artifactId>
114137
<groupId>org.slf4j</groupId>
115138
</exclusion>
116139
</exclusions>
117140
</dependency>
141+
118142
<dependency>
119143
<groupId>org.apache.hadoop</groupId>
120144
<artifactId>hadoop-core</artifactId>
121145
<version>1.2.1</version>
122146
</dependency>
123147

124-
125148
<dependency>
126149
<groupId>com.thoughtworks.qdox</groupId>
127150
<artifactId>qdox</artifactId>
128151
<version>2.0-M3</version>
129152
</dependency>
130153

131-
132-
133-
<dependency>
134-
<groupId>com.google.code.gson</groupId>
135-
<artifactId>gson</artifactId>
136-
<version>2.6.2</version>
137-
</dependency>
138-
<dependency>
139-
<groupId>jline</groupId>
140-
<artifactId>jline</artifactId>
141-
<version>2.12</version>
142-
</dependency>
143-
144-
145154
<dependency>
146155
<groupId>org.apache.beam</groupId>
147156
<artifactId>beam-runners-parent</artifactId>
148-
<version>0.1.0-incubating</version>
157+
<version>${beam.beam.version}</version>
149158
<type>pom</type>
150159
</dependency>
151160

152161
<dependency>
153162
<groupId>org.apache.beam</groupId>
154163
<artifactId>beam-runners-core-java</artifactId>
155-
<version>0.1.0-incubating</version>
164+
<version>${beam.beam.version}</version>
156165
<exclusions>
157166
<exclusion>
158167
<artifactId>google-http-client-jackson2</artifactId>
159168
<groupId>com.google.http-client</groupId>
160169
</exclusion>
161170
</exclusions>
162171
</dependency>
172+
163173
<dependency>
164174
<groupId>org.apache.beam</groupId>
165175
<artifactId>beam-runners-direct-java</artifactId>
166-
<version>0.1.0-incubating</version>
167-
176+
<version>${beam.beam.version}</version>
168177
</dependency>
178+
169179
<dependency>
170180
<groupId>org.apache.beam</groupId>
171181
<artifactId>beam-runners-flink_2.10</artifactId>
172-
<version>0.1.0-incubating</version>
182+
<version>${beam.beam.version}</version>
173183

174184
<exclusions>
175185
<exclusion>
@@ -183,10 +193,11 @@
183193

184194
</exclusions>
185195
</dependency>
196+
186197
<dependency>
187198
<groupId>org.apache.beam</groupId>
188199
<artifactId>beam-runners-flink_2.10-examples</artifactId>
189-
<version>0.1.0-incubating</version>
200+
<version>${beam.beam.version}</version>
190201

191202
<exclusions>
192203
<exclusion>
@@ -199,7 +210,7 @@
199210
<dependency>
200211
<groupId>org.apache.beam</groupId>
201212
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
202-
<version>0.1.0-incubating</version>
213+
<version>${beam.beam.version}</version>
203214

204215
<exclusions>
205216
<exclusion>
@@ -208,23 +219,21 @@
208219
</exclusion>
209220
</exclusions>
210221
</dependency>
211-
<dependency>
212222

223+
<dependency>
213224
<groupId>org.apache.beam</groupId>
214225
<artifactId>beam-runners-spark</artifactId>
215-
<version>0.1.0-incubating</version>
226+
<version>${beam.beam.version}</version>
216227
<type>jar</type>
217228
</dependency>
218229

219-
220-
221-
222230
<dependency>
223231
<groupId>${project.groupId}</groupId>
224232
<artifactId>zeppelin-interpreter</artifactId>
225233
<version>${project.version}</version>
226234
<scope>provided</scope>
227235
</dependency>
236+
228237
<dependency>
229238
<groupId>org.apache.commons</groupId>
230239
<artifactId>commons-exec</artifactId>
@@ -242,8 +251,6 @@
242251
<build>
243252
<plugins>
244253

245-
246-
247254
<plugin>
248255
<groupId>org.apache.maven.plugins</groupId>
249256
<artifactId>maven-deploy-plugin</artifactId>

beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.zeppelin.beam;
219

320
import java.io.File;
4-
import java.io.PrintWriter;
5-
import java.io.StringWriter;
6-
import java.util.Date;
721
import java.util.List;
8-
import java.util.Map;
922
import java.util.Properties;
1023
import java.util.UUID;
1124

1225
import org.apache.zeppelin.interpreter.Interpreter;
1326
import org.apache.zeppelin.interpreter.InterpreterContext;
14-
import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
1527
import org.apache.zeppelin.interpreter.InterpreterResult;
1628
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
17-
18-
import com.google.gson.Gson;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
1931

2032
/**
33+
* Beam interpreter
2134
*
2235
*/
2336
public class BeamInterpreter extends Interpreter {
2437

38+
Logger LOGGER = LoggerFactory.getLogger(BeamInterpreter.class);
39+
2540
public BeamInterpreter(Properties property) {
2641
super(property);
2742
}
@@ -34,6 +49,7 @@ public void open() {
3449
@Override
3550
public void close() {
3651
File dir = new File(".");
52+
// delete all .class files created while compilation process
3753
for (int i = 0; i < dir.list().length; i++) {
3854
File f = dir.listFiles()[i];
3955
if (f.getAbsolutePath().contains(".class"))
@@ -44,13 +60,14 @@ public void close() {
4460
@Override
4561
public InterpreterResult interpret(String code, InterpreterContext context) {
4662

47-
String className = "C" + UUID.randomUUID().toString().replace("-", "");
63+
// choosing new name to class containing Main method
64+
String generatedClassName = "C" + UUID.randomUUID().toString().replace("-", "");
4865

4966
try {
50-
String msg = StaticRepl.execute(className, code);
51-
return new InterpreterResult(InterpreterResult.Code.SUCCESS, msg);
67+
String res = StaticRepl.execute(generatedClassName, code);
68+
return new InterpreterResult(InterpreterResult.Code.SUCCESS, res);
5269
} catch (Exception e) {
53-
// e.printStackTrace();
70+
LOGGER.error("Exception in Interpreter while interpret", e);
5471
return new InterpreterResult(InterpreterResult.Code.ERROR, e.getMessage());
5572

5673
}

0 commit comments

Comments
 (0)