Commits

Miguel Ángel García committed eadd51a

added worker skeleton

Comments (0)

Files changed (5)

distribot-comms/src/main/resources/distribot.ice

         string name;
     };
 
+    struct TaskDefinition {
+        string name;
+    };
+
     interface Core {
         bool check ();
     };
         bool check ();
         void execute ( JobDefinition jobdef);
     };
+
+    interface Worker {
+        bool check ();
+        void execute ( TaskDefinition task );
+    };
 };

distribot-worker/pom.xml

+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.magmax.distribot</groupId>
+        <artifactId>distribot</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.magmax.distribot</groupId>
+    <artifactId>distribot-worker</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>distribot-worker</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <netbeans.hint.license>gpl30</netbeans.hint.license>
+        <resource.encoding>UTF-8</resource.encoding>
+        <jdk.version>1.6</jdk.version>
+    </properties>
+	
+    <dependencies>
+        <dependency>
+            <groupId>org.magmax.distribot</groupId>
+            <artifactId>distribot-comms</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <mainClass>org.magmax.distribot.worker.Main.class</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

distribot-worker/src/main/java/org/magmax/distribot/worker/Main.java

+/*
+ * Copyright (C) 2012 Miguel Angel Garcia <miguelangel.garcia@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.magmax.distribot.worker;
+
+/**
+ *
+ * @author Miguel Angel Garcia <miguelangel.garcia@gmail.com>
+ */
+public class Main {
+
+    public static void main(String[] args) {
+        int status = 0;
+        Ice.Communicator ic = null;
+        try {
+            ic = Ice.Util.initialize(args);
+            Ice.ObjectAdapter adapter =
+                    ic.createObjectAdapterWithEndpoints("DistribotExecutorAdapter", "default -p 10000");
+            Ice.Object object = new Worker();
+            adapter.add(object, ic.stringToIdentity("DistribotExecutor"));
+            adapter.activate();
+            ic.waitForShutdown();
+        } catch (Ice.LocalException e) {
+            e.printStackTrace();
+            status = 1;
+        } catch (Exception e) {
+            System.err.println(e.getMessage());
+            status = 1;
+        }
+        if (ic != null) {
+            try {
+                ic.destroy();
+            } catch (Exception e) {
+                System.err.println(e.getMessage());
+                status = 1;
+            }
+        }
+        System.exit(status);
+    }
+}

distribot-worker/src/main/java/org/magmax/distribot/worker/Worker.java

+/*
+ * Copyright (C) 2012 Miguel Angel Garcia <miguelangel.garcia@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.magmax.distribot.worker;
+
+import Distribot.JobDefinition;
+import Distribot.TaskDefinition;
+import Ice.Current;
+
+/**
+ *
+ * @author Miguel Angel Garcia <miguelangel.garcia@gmail.com>
+ */
+public class Worker extends Distribot._WorkerDisp{
+
+    public boolean check(Current crnt) {
+        return true;
+    }
+
+    public void execute(TaskDefinition td, Current crnt) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+}
 	<modules>
 		<module>distribot-comms</module>
                 <module>distribot-executor</module>
+                <module>distribot-worker</module>
 	</modules>
 
 	<dependencies>