Revision 47555
Added by Marek Horst almost 7 years ago
modules/icm-iis-oozie-maven-plugin/trunk/pom.xml.disabled | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
</parent> |
|
8 |
|
|
9 |
<version>0.0.2-SNAPSHOT</version> |
|
10 |
<modelVersion>4.0.0</modelVersion> |
|
11 |
<artifactId>icm-iis-oozie-maven-plugin</artifactId> |
|
12 |
<packaging>maven-plugin</packaging> |
|
13 |
|
|
14 |
<scm> |
|
15 |
<developerConnection> |
|
16 |
scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/icm-iis-oozie-maven-plugin/trunk |
|
17 |
</developerConnection> |
|
18 |
</scm> |
|
19 |
|
|
20 |
<properties> |
|
21 |
</properties> |
|
22 |
|
|
23 |
<repositories> |
|
24 |
<repository> |
|
25 |
<id>dnet-deps</id> |
|
26 |
<name>dnet-dependencies</name> |
|
27 |
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/dnet-deps</url> |
|
28 |
<layout>default</layout> |
|
29 |
</repository> |
|
30 |
<repository> |
|
31 |
<id>cloudera</id> |
|
32 |
<name>Cloudera Repository</name> |
|
33 |
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url> |
|
34 |
<releases> |
|
35 |
<enabled>true</enabled> |
|
36 |
</releases> |
|
37 |
<snapshots> |
|
38 |
<enabled>false</enabled> |
|
39 |
</snapshots> |
|
40 |
</repository> |
|
41 |
</repositories> |
|
42 |
|
|
43 |
<dependencies> |
|
44 |
<dependency> |
|
45 |
<groupId>org.apache.maven</groupId> |
|
46 |
<artifactId>maven-plugin-api</artifactId> |
|
47 |
<version>2.0</version> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.apache.maven</groupId> |
|
51 |
<artifactId>maven-project</artifactId> |
|
52 |
<version>2.0</version> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>org.apache.oozie</groupId> |
|
56 |
<artifactId>oozie-client</artifactId> |
|
57 |
<version>${iis.oozie.version}</version> |
|
58 |
<exclusions> |
|
59 |
<exclusion> |
|
60 |
<artifactId>slf4j-simple</artifactId> |
|
61 |
<groupId>org.slf4j</groupId> |
|
62 |
</exclusion> |
|
63 |
</exclusions> |
|
64 |
</dependency> |
|
65 |
</dependencies> |
|
66 |
<build> |
|
67 |
<directory>target</directory> |
|
68 |
<outputDirectory>target/classes</outputDirectory> |
|
69 |
<finalName>${project.artifactId}-${project.version}</finalName> |
|
70 |
<testOutputDirectory>target/test-classes</testOutputDirectory> |
|
71 |
<plugins> |
|
72 |
<plugin> |
|
73 |
<groupId>org.apache.maven.plugins</groupId> |
|
74 |
<artifactId>maven-compiler-plugin</artifactId> |
|
75 |
<version>2.3.2</version> |
|
76 |
<configuration> |
|
77 |
<source>1.6</source> |
|
78 |
<target>1.6</target> |
|
79 |
</configuration> |
|
80 |
</plugin> |
|
81 |
<plugin> |
|
82 |
<groupId>org.apache.maven.plugins</groupId> |
|
83 |
<artifactId>maven-source-plugin</artifactId> |
|
84 |
<version>2.1.2</version> |
|
85 |
<executions> |
|
86 |
<execution> |
|
87 |
<id>attach-sources</id> |
|
88 |
<phase>verify</phase> |
|
89 |
<goals> |
|
90 |
<goal>jar-no-fork</goal> |
|
91 |
</goals> |
|
92 |
</execution> |
|
93 |
</executions> |
|
94 |
</plugin> |
|
95 |
</plugins> |
|
96 |
<pluginManagement> |
|
97 |
<plugins> |
|
98 |
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> |
|
99 |
<plugin> |
|
100 |
<groupId>org.eclipse.m2e</groupId> |
|
101 |
<artifactId>lifecycle-mapping</artifactId> |
|
102 |
<version>1.0.0</version> |
|
103 |
<configuration> |
|
104 |
<lifecycleMappingMetadata> |
|
105 |
<pluginExecutions> |
|
106 |
<pluginExecution> |
|
107 |
<pluginExecutionFilter> |
|
108 |
<groupId> |
|
109 |
org.apache.maven.plugins |
|
110 |
</groupId> |
|
111 |
<artifactId> |
|
112 |
maven-plugin-plugin |
|
113 |
</artifactId> |
|
114 |
<versionRange>[3.2,)</versionRange> |
|
115 |
<goals> |
|
116 |
<goal>descriptor</goal> |
|
117 |
</goals> |
|
118 |
</pluginExecutionFilter> |
|
119 |
<action> |
|
120 |
<ignore /> |
|
121 |
</action> |
|
122 |
</pluginExecution> |
|
123 |
</pluginExecutions> |
|
124 |
</lifecycleMappingMetadata> |
|
125 |
</configuration> |
|
126 |
</plugin> |
|
127 |
</plugins> |
|
128 |
</pluginManagement> |
|
129 |
</build> |
|
130 |
|
|
131 |
<distributionManagement> |
|
132 |
<repository> |
|
133 |
<id>dnet4-bootstrap-release</id> |
|
134 |
<url> |
|
135 |
http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-bootstrap-release |
|
136 |
</url> |
|
137 |
</repository> |
|
138 |
</distributionManagement> |
|
139 |
|
|
140 |
</project> |
|
0 | 141 |
modules/icm-iis-oozie-maven-plugin/trunk/src/main/java/eu/dnetlib/maven/plugin/oozie/ReadJobId.java | ||
---|---|---|
1 |
package eu.dnetlib.maven.plugin.oozie; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileInputStream; |
|
6 |
import java.io.FileNotFoundException; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStreamReader; |
|
9 |
|
|
10 |
import org.apache.maven.plugin.AbstractMojo; |
|
11 |
import org.apache.maven.plugin.MojoExecutionException; |
|
12 |
import org.apache.maven.plugin.MojoFailureException; |
|
13 |
import org.apache.maven.project.MavenProject; |
|
14 |
import org.codehaus.plexus.util.StringUtils; |
|
15 |
|
|
16 |
/** |
|
17 |
* Read oozie job identifier from log file. |
|
18 |
* @author mhorst |
|
19 |
* |
|
20 |
* @goal read-job-id |
|
21 |
*/ |
|
22 |
public class ReadJobId extends AbstractMojo { |
|
23 |
|
|
24 |
|
|
25 |
public static final String PROPERTY_NAME_LOG_FILE_LOCATION = "logFileLocation"; |
|
26 |
|
|
27 |
public static final String PROPERTY_NAME_OOZIE_JOB_ID = "oozieJobId"; |
|
28 |
|
|
29 |
public static final String OOZIE_JOB_LOG_LINE_TOKEN_SEPARATOR = ":"; |
|
30 |
|
|
31 |
public static final String OOZIE_JOB_LOG_LINE_PREFIX = "job" + OOZIE_JOB_LOG_LINE_TOKEN_SEPARATOR; |
|
32 |
|
|
33 |
/** |
|
34 |
* @parameter expression="${properties.logFileLocation}" |
|
35 |
*/ |
|
36 |
private String logFileLocation; |
|
37 |
|
|
38 |
/** @parameter default-value="${project}" */ |
|
39 |
private MavenProject project; |
|
40 |
|
|
41 |
@Override |
|
42 |
public void execute() throws MojoExecutionException, MojoFailureException { |
|
43 |
String extractedOozieJobId = extractOozieJobId(logFileLocation); |
|
44 |
if (extractedOozieJobId!=null) { |
|
45 |
project.getProperties().setProperty(PROPERTY_NAME_OOZIE_JOB_ID, |
|
46 |
extractedOozieJobId); |
|
47 |
System.out.println("extracted job identifier: " + extractedOozieJobId); |
|
48 |
} else { |
|
49 |
throw new MojoFailureException("unable to extract oozie job identifier from log file: " + |
|
50 |
logFileLocation); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Extracts oozie job identifier from log file |
|
56 |
* @param logFileLocation |
|
57 |
* @return extracted oozie job identifier |
|
58 |
* @throws MojoExecutionException |
|
59 |
*/ |
|
60 |
private String extractOozieJobId(String logFileLocation) throws MojoExecutionException { |
|
61 |
try { |
|
62 |
BufferedReader reader = new BufferedReader(new InputStreamReader( |
|
63 |
new FileInputStream(new File(logFileLocation)))); |
|
64 |
String line; |
|
65 |
try { |
|
66 |
while ((line = reader.readLine())!=null) { |
|
67 |
String trimmedLine = line.trim(); |
|
68 |
if (trimmedLine.startsWith(OOZIE_JOB_LOG_LINE_PREFIX)) { |
|
69 |
String[] split = StringUtils.split(trimmedLine, OOZIE_JOB_LOG_LINE_TOKEN_SEPARATOR); |
|
70 |
if (split.length == 2) { |
|
71 |
return split[1].trim(); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 |
return null; |
|
76 |
} finally { |
|
77 |
reader.close(); |
|
78 |
} |
|
79 |
} catch (FileNotFoundException e) { |
|
80 |
throw new MojoExecutionException("unable to read log file: " + |
|
81 |
logFileLocation, e); |
|
82 |
} catch (IOException e) { |
|
83 |
throw new MojoExecutionException("error occurred when reading log file: " + |
|
84 |
logFileLocation, e); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
} |
|
0 | 89 |
modules/icm-iis-oozie-maven-plugin/trunk/src/main/java/eu/dnetlib/maven/plugin/oozie/CheckJobStatus.java | ||
---|---|---|
1 |
package eu.dnetlib.maven.plugin.oozie; |
|
2 |
|
|
3 |
import org.apache.maven.plugin.AbstractMojo; |
|
4 |
import org.apache.maven.plugin.MojoExecutionException; |
|
5 |
import org.apache.maven.plugin.MojoFailureException; |
|
6 |
import org.apache.oozie.client.OozieClient; |
|
7 |
import org.apache.oozie.client.OozieClientException; |
|
8 |
import org.apache.oozie.client.WorkflowJob.Status; |
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* Checks oozie job status. |
|
14 |
* @author mhorst |
|
15 |
* |
|
16 |
* @goal check-job-status |
|
17 |
*/ |
|
18 |
public class CheckJobStatus extends AbstractMojo { |
|
19 |
|
|
20 |
|
|
21 |
public static final String PROPERTY_NAME_LOG_FILE_LOCATION = "logFileLocation"; |
|
22 |
|
|
23 |
/** |
|
24 |
* @parameter expression="${properties.oozieLocation}" |
|
25 |
*/ |
|
26 |
private String oozieLocation; |
|
27 |
|
|
28 |
/** |
|
29 |
* @parameter expression="${properties.jobId}" |
|
30 |
*/ |
|
31 |
private String jobId; |
|
32 |
|
|
33 |
/** |
|
34 |
* @parameter expression="${properties.maxExecutionTimeMins}" |
|
35 |
*/ |
|
36 |
private Integer maxExecutionTimeMins; |
|
37 |
|
|
38 |
/** |
|
39 |
* @parameter expression="${properties.checkIntervalSecs}" |
|
40 |
*/ |
|
41 |
private Integer checkIntervalSecs = 60; |
|
42 |
|
|
43 |
@Override |
|
44 |
public void execute() throws MojoExecutionException, MojoFailureException { |
|
45 |
OozieClient oozieClient = new OozieClient(oozieLocation); |
|
46 |
// OozieClient oozieClient = new AuthOozieClient(oozieLocation); |
|
47 |
long maxExecutionTime = 1000L * 60 * maxExecutionTimeMins; |
|
48 |
long checkInterval = 1000L * checkIntervalSecs; |
|
49 |
long startTime = System.currentTimeMillis(); |
|
50 |
try { |
|
51 |
try { |
|
52 |
while ((System.currentTimeMillis()-startTime)<maxExecutionTime) { |
|
53 |
Thread.sleep(checkInterval); |
|
54 |
Status status = oozieClient.getJobInfo(jobId).getStatus(); |
|
55 |
if (Status.SUCCEEDED.equals(status)) { |
|
56 |
getLog().info("job SUCCEEDED"); |
|
57 |
return; |
|
58 |
} else if (Status.FAILED.equals(status) || Status.KILLED.equals(status)) { |
|
59 |
System.out.print(oozieClient.getJobLog(jobId)); |
|
60 |
throw new MojoFailureException("job " + jobId + " finished with status: " + status); |
|
61 |
} else { |
|
62 |
getLog().info("job " + jobId + " is still running with status: " + status); |
|
63 |
} |
|
64 |
} |
|
65 |
System.out.print(oozieClient.getJobLog(jobId)); |
|
66 |
throw new MojoFailureException("Maximum execution time has passed!"); |
|
67 |
|
|
68 |
} catch (InterruptedException e) { |
|
69 |
System.out.print(oozieClient.getJobLog(jobId)); |
|
70 |
throw new MojoExecutionException("exception occured while sleeping", e); |
|
71 |
} |
|
72 |
} catch (OozieClientException e) { |
|
73 |
throw new MojoExecutionException("exception occured when obtaining status from oozie", e); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
} |
|
0 | 78 |
modules/icm-iis-oozie-maven-plugin/trunk/deploy.info.disabled | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U -T 4C source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/icm-iis-oozie-maven-plugin/trunk/", |
|
5 |
"deploy_repository": "dnet4-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "m.horst@icm.edu.pl", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-bootstrap-snapshot", |
|
9 |
"name": "icm-iis-oozie-maven-plugin" |
|
10 |
} |
modules/icm-iis-oozie-maven-plugin/trunk/README.markdown | ||
---|---|---|
1 |
Maven plugin module prepared for oozie communication required by test verification profile. |
Also available in: Unified diff
introducing dnet45 version of IIS CDH4 legacy libs