Permalink
Browse files

added dns bootstrapper but doesn't do the right thing yet.

  • Loading branch information...
1 parent 5588989 commit d171e6be92de515c55133a9b4a3e0f504e846bfa Neil committed Aug 13, 2009
@@ -0,0 +1,54 @@
+package com.eucalyptus.bootstrap;
+
+import org.apache.log4j.Logger;
+
+import com.eucalyptus.auth.util.EucaKeyStore;
+import com.eucalyptus.bootstrap.Bootstrapper;
+import com.eucalyptus.cloud.ws.DNSControl;
+
+public class DNSBootstrapper extends Bootstrapper {
+ private static Logger LOG = Logger.getLogger( DNSBootstrapper.class );
+ private static DNSBootstrapper singleton;
+
+ public static Bootstrapper getInstance( ) {
+ synchronized ( DNSBootstrapper.class ) {
+ if ( singleton == null ) {
+ singleton = new DNSBootstrapper( );
+ LOG.info( "Creating DNS Bootstrapper instance." );
+ } else {
+ LOG.info( "Returning DNS Bootstrapper instance." );
+ }
+ }
+ return singleton;
+ }
+
+ @Override
+ public boolean check( ) throws Exception {
+ return true;
+ }
+
+ @Override
+ public boolean destroy( ) throws Exception {
+ return true;
+ }
+
+ @Override
+ public boolean load( ) throws Exception {
+ SystemBootstrapper.hello();
+ LOG.info("Initializing DNS");
+ DNSControl.initialize();
+ SystemBootstrapper.hello();
+ return true;
+ }
+
+ @Override
+ public boolean start( ) throws Exception {
+ return true;
+ }
+
+ @Override
+ public boolean stop( ) throws Exception {
+ return true;
+ }
+
+}
@@ -51,10 +51,10 @@
public class DNSControl {
private static Logger LOG = Logger.getLogger( DNSControl.class );
- static {
+ /*static {
initialize();
populateRecords();
- }
+ }*/
private static void initializeUDP() {
try {
@@ -42,26 +42,37 @@
import java.net.Socket;
public class TCPListener extends Thread {
- private static Logger LOG = Logger.getLogger( TCPListener.class );
- InetAddress address;
- int port;
+ private static Logger LOG = Logger.getLogger( TCPListener.class );
+ InetAddress address;
+ int port;
+ ServerSocket socket;
- public TCPListener(InetAddress address, int port) {
- this.address = address;
- this.port = port;
- }
+ public TCPListener(InetAddress address, int port) {
+ this.address = address;
+ this.port = port;
+ try {
+ socket = new ServerSocket(port, 128, address);
+ } catch(IOException ex) {
+ LOG.error(ex);
+ }
- public void run() {
- try {
- LOG.info("start");
- ServerSocket sock = new ServerSocket(port, 128, address);
- while (true) {
- LOG.info("Listening on port: " + port);
- final Socket s = sock.accept();
- ConnectionHandlerFactory.handle(s);
- }
- } catch(IOException ex) {
- LOG.error(ex);
- }
- }
+ }
+
+ public void run() {
+ while (true) {
+ Socket s;
+ try {
+ if(socket != null) {
+ LOG.info("Listening on port: " + port);
+ s = socket.accept();
+ ConnectionHandlerFactory.handle(s);
+ } else {
+ LOG.error("Cannot start service. Invalid socket.");
+ return;
+ }
+ } catch (IOException e) {
+ LOG.error(e);
+ }
+ }
+ }
}
@@ -41,21 +41,25 @@
import java.net.InetAddress;
public class UDPListener extends Thread {
- private static Logger LOG = Logger.getLogger( UDPListener.class );
- InetAddress address;
- int port;
+ private static Logger LOG = Logger.getLogger( UDPListener.class );
+ InetAddress address;
+ int port;
+ DatagramSocket socket;
- public UDPListener(InetAddress address, int port) {
- this.address = address;
- this.port = port;
- }
+ public UDPListener(InetAddress address, int port) {
+ this.address = address;
+ this.port = port;
+ try {
+ socket = new DatagramSocket(port, address);
+ } catch(Exception ex) {
+ LOG.error(ex);
+ }
+ }
- public void run() {
- try {
- DatagramSocket socket = new DatagramSocket(port, address);
- ConnectionHandlerFactory.handle(socket);
- } catch(IOException ex) {
- LOG.error(ex);
- }
- }
+ public void run() {
+ if(socket != null)
+ ConnectionHandlerFactory.handle(socket);
+ else
+ LOG.error("Cannot start service. Invalid socket.");
+ }
}
@@ -150,5 +150,5 @@ public boolean check( ) {
private static native void shutdown( boolean reload );
- private static native void hello( );
+ public static native void hello( );
}
@@ -38,6 +38,7 @@ public ServiceJarFile( File f ) throws IOException {
while ( jarList.hasMoreElements( ) ) {
JarEntry j = jarList.nextElement( );
if ( Bootstrapper.PROPERTIES.equals( j.getName( ) ) ) {
+ LOG.info("Found properties: " + j.getName());
try {
InputStream in = this.getInputStream( j );
props.load( in );
@@ -104,6 +105,7 @@ private Class getBootstrapper( JarEntry j ) throws Exception {
throw new InstantiationException( candidate.getCanonicalName( ) + " does not declare public <init>()V or public static getInstance()L;" );
}
}
+ LOG.info("Found bootstrapper: " + candidate.getName());
return candidate;
}
}

0 comments on commit d171e6b

Please sign in to comment.