You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by om...@apache.org on 2011/09/22 18:14:02 UTC
svn commit: r1174242 [5/9] - in /incubator/ambari/trunk: ./ agent/
agent/bin/ agent/conf/ agent/src/ agent/src/main/ agent/src/main/python/
agent/src/main/python/ambari_agent/ agent/src/main/python/ambari_torrent/
agent/src/main/python/ambari_torrent/h...
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscovery.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscovery.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscovery.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.common.util;
+
+ import java.awt.BorderLayout;
+ import java.awt.Color;
+ import java.awt.Container;
+ import java.awt.GridLayout;
+ import java.io.IOException;
+ import java.util.Enumeration;
+ import java.util.Vector;
+
+ import javax.jmdns.JmDNS;
+ import javax.jmdns.ServiceEvent;
+ import javax.jmdns.ServiceInfo;
+ import javax.jmdns.ServiceListener;
+ import javax.jmdns.ServiceTypeListener;
+ import javax.swing.DefaultListModel;
+ import javax.swing.JFrame;
+ import javax.swing.JLabel;
+ import javax.swing.JList;
+ import javax.swing.JPanel;
+ import javax.swing.JScrollPane;
+ import javax.swing.JTextArea;
+ import javax.swing.ListSelectionModel;
+ import javax.swing.SwingUtilities;
+ import javax.swing.border.EmptyBorder;
+ import javax.swing.event.ListSelectionEvent;
+ import javax.swing.event.ListSelectionListener;
+ import javax.swing.table.AbstractTableModel;
+
+ /**
+ * User Interface for browsing JmDNS services.
+ *
+ * @author Arthur van Hoff, Werner Randelshofer
+ * @version %I%, %G%
+ */
+ public class ServiceDiscovery extends JFrame implements ServiceListener, ServiceTypeListener, ListSelectionListener {
+ JmDNS jmdns;
+ Vector headers;
+ String type;
+ DefaultListModel types;
+ JList typeList;
+ DefaultListModel services;
+ JList serviceList;
+ JTextArea info;
+
+ ServiceDiscovery(JmDNS jmdns) throws IOException {
+ super("JmDNS Browser");
+ this.jmdns = jmdns;
+
+ Color bg = new Color(230, 230, 230);
+ EmptyBorder border = new EmptyBorder(5, 5, 5, 5);
+ Container content = getContentPane();
+ content.setLayout(new GridLayout(1, 3));
+
+ types = new DefaultListModel();
+ typeList = new JList(types);
+ typeList.setBorder(border);
+ typeList.setBackground(bg);
+ typeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ typeList.addListSelectionListener(this);
+
+ JPanel typePanel = new JPanel();
+ typePanel.setLayout(new BorderLayout());
+ typePanel.add("North", new JLabel("Types"));
+ typePanel.add("Center", new JScrollPane(typeList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
+ content.add(typePanel);
+
+ services = new DefaultListModel();
+ serviceList = new JList(services);
+ serviceList.setBorder(border);
+ serviceList.setBackground(bg);
+ serviceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ serviceList.addListSelectionListener(this);
+
+ JPanel servicePanel = new JPanel();
+ servicePanel.setLayout(new BorderLayout());
+ servicePanel.add("North", new JLabel("Services"));
+ servicePanel.add("Center", new JScrollPane(serviceList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
+ content.add(servicePanel);
+
+ info = new JTextArea();
+ info.setBorder(border);
+ info.setBackground(bg);
+ info.setEditable(false);
+ info.setLineWrap(true);
+
+ JPanel infoPanel = new JPanel();
+ infoPanel.setLayout(new BorderLayout());
+ infoPanel.add("North", new JLabel("Details"));
+ infoPanel.add("Center", new JScrollPane(info, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
+ content.add(infoPanel);
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setLocation(100, 100);
+ setSize(600, 400);
+
+ jmdns.addServiceTypeListener(this);
+
+ // register some well known types
+ String list[] = new String[] {
+ "_http._tcp.local.",
+ "_ftp._tcp.local.",
+ "_tftp._tcp.local.",
+ "_ssh._tcp.local.",
+ "_smb._tcp.local.",
+ "_printer._tcp.local.",
+ "_airport._tcp.local.",
+ "_afpovertcp._tcp.local.",
+ "_ichat._tcp.local.",
+ "_eppc._tcp.local.",
+ "_presence._tcp.local.",
+ "_zookeeper._tcp.local.",
+ "_test._tcp.local."
+ };
+
+ for (int i = 0 ; i < list.length ; i++) {
+ jmdns.registerServiceType(list[i]);
+ }
+
+ show();
+ }
+
+ /**
+ * Add a service.
+ */
+ public void serviceAdded(ServiceEvent event) {
+ final String name = event.getName();
+
+ System.out.println("ADD: " + name);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() { insertSorted(services, name); }
+ });
+ }
+
+ /**
+ * Remove a service.
+ */
+ public void serviceRemoved(ServiceEvent event) {
+ final String name = event.getName();
+
+ System.out.println("REMOVE: " + name);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() { services.removeElement(name); }
+ });
+ }
+
+ /**
+ * A new service type was <discovered.
+ */
+ public void serviceTypeAdded(ServiceEvent event) {
+ final String type = event.getType();
+
+ System.out.println("TYPE: " + type);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() { insertSorted(types, type); }
+ });
+ }
+
+
+ void insertSorted(DefaultListModel model, String value) {
+ for (int i = 0, n = model.getSize() ; i < n ; i++) {
+ if (value.compareToIgnoreCase((String)model.elementAt(i)) < 0) {
+ model.insertElementAt(value, i);
+ return;
+ }
+ }
+ model.addElement(value);
+ }
+
+ /**
+ * Resolve a service.
+ */
+ public void serviceResolved(ServiceEvent event) {
+ String name = event.getName();
+ String type = event.getType();
+ ServiceInfo info = event.getInfo();
+
+ if (name.equals(serviceList.getSelectedValue())) {
+ if (info == null) {
+ this.info.setText("service not found");
+ } else {
+
+ StringBuffer buf = new StringBuffer();
+ buf.append(name);
+ buf.append('.');
+ buf.append(type);
+ buf.append('\n');
+ buf.append(info.getServer());
+ buf.append(':');
+ buf.append(info.getPort());
+ buf.append('\n');
+ buf.append(info.getAddress());
+ buf.append(':');
+ buf.append(info.getPort());
+ buf.append('\n');
+ for (Enumeration names = info.getPropertyNames() ; names.hasMoreElements() ; ) {
+ String prop = (String)names.nextElement();
+ buf.append(prop);
+ buf.append('=');
+ buf.append(info.getPropertyString(prop));
+ buf.append('\n');
+ }
+
+ this.info.setText(buf.toString());
+ }
+ }
+ }
+
+ /**
+ * List selection changed.
+ */
+ public void valueChanged(ListSelectionEvent e) {
+ if (!e.getValueIsAdjusting()) {
+ if (e.getSource() == typeList) {
+ type = (String)typeList.getSelectedValue();
+ jmdns.removeServiceListener(type, this);
+ services.setSize(0);
+ info.setText("");
+ if (type != null) {
+ jmdns.addServiceListener(type, this);
+ }
+ } else if (e.getSource() == serviceList) {
+ String name = (String)serviceList.getSelectedValue();
+ if (name == null) {
+ info.setText("");
+ } else {
+ System.out.println(this+" valueChanged() type:"+type+" name:"+name);
+ System.out.flush();
+ ServiceInfo service = jmdns.getServiceInfo(type, name);
+ if (service == null) {
+ info.setText("service not found");
+ } else {
+ jmdns.requestServiceInfo(type, name);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Table data.
+ */
+ class ServiceTableModel extends AbstractTableModel {
+ public String getColumnName(int column) {
+ switch (column) {
+ case 0: return "service";
+ case 1: return "address";
+ case 2: return "port";
+ case 3: return "text";
+ }
+ return null;
+ }
+ public int getColumnCount() {
+ return 1;
+ }
+ public int getRowCount() {
+ return services.size();
+ }
+ public Object getValueAt(int row, int col) {
+ return services.elementAt(row);
+ }
+ }
+
+ public String toString() {
+ return "RVBROWSER";
+ }
+
+ /**
+ * Main program.
+ */
+ public static void main(String argv[]) throws IOException {
+ new ServiceDiscovery(JmDNS.create());
+ }
+
+ @Override
+ public void subTypeForServiceTypeAdded(ServiceEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+}
Propchange: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscovery.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscoveryUtil.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscoveryUtil.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscoveryUtil.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscoveryUtil.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.common.util;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jmdns.JmDNS;
+import javax.jmdns.ServiceEvent;
+import javax.jmdns.ServiceInfo;
+import javax.jmdns.ServiceListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ServiceDiscoveryUtil implements ServiceListener {
+ private static Log LOG = LogFactory.getLog(ServiceDiscoveryUtil.class);
+ public static JmDNS jmdns;
+ private InetAddress addr;
+ private Map<String, String> map;
+ private String type;
+
+ /** Number of milliseconds to wait for service info resolution before giving up */
+ private final static int SERVICE_RESOLUTION_TIMEOUT = 10000;
+
+ public ServiceDiscoveryUtil() throws IOException {
+ map = new HashMap<String, String>();
+ type = "_zookeeper._tcp.local.";
+ }
+
+ public ServiceDiscoveryUtil(String type) throws IOException {
+ this();
+ this.type = type;
+ }
+
+ public ServiceDiscoveryUtil(InetAddress addr, String type) throws IOException {
+ this();
+ this.addr = addr;
+ this.type = type;
+ }
+
+ public void start() throws IOException {
+ if(addr!=null) {
+ jmdns = JmDNS.create(this.addr);
+ } else {
+ jmdns = JmDNS.create();
+ }
+ jmdns.addServiceListener(type, this);
+ }
+
+ /**
+ * Add a service.
+ */
+ public void serviceAdded(final ServiceEvent event) {
+ String name = event.getName();
+ LOG.info("Add: " + name + " Type: " + event.getType());
+ new Thread() {
+ public void run() {
+ jmdns.requestServiceInfo(event.getType(), event.getName(), SERVICE_RESOLUTION_TIMEOUT);
+ }
+ }.start();
+ }
+
+ /**
+ * Remove a service.
+ */
+ public void serviceRemoved(ServiceEvent event) {
+ String name = event.getName();
+ map.remove(name);
+ LOG.info("Remove: " + name + " Type: " + event.getType());
+ }
+
+ /**
+ * Resolve a service.
+ */
+ public synchronized void serviceResolved(ServiceEvent event) {
+ String name = event.getName();
+ String type = event.getType();
+ if(type.equals(this.type)) {
+ ServiceInfo info = event.getInfo();
+ StringBuffer buf = new StringBuffer();
+ String delimiter = "";
+ for(String addr : info.getHostAddresses()) {
+ buf.append(delimiter);
+ buf.append(addr);
+ buf.append(':');
+ buf.append(info.getPort());
+ delimiter = ",";
+ }
+ LOG.debug("Resolved: " + buf.toString());
+ map.put(name, buf.toString());
+ }
+ }
+
+ public Collection<String> resolve() {
+ return (Collection<String>) map.values();
+ }
+
+ public void close() throws IOException {
+ jmdns.close();
+ }
+}
Propchange: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/util/ServiceDiscoveryUtil.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AbstractEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AbstractEvent.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AbstractEvent.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AbstractEvent.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,57 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.event;
+
+/**
+ * parent class of all the events. All events extend this class.
+ */
+public abstract class AbstractEvent<TYPE extends Enum<TYPE>>
+ implements Event<TYPE> {
+
+ private final TYPE type;
+ private final long timestamp;
+
+ // use this if you DON'T care about the timestamp
+ public AbstractEvent(TYPE type) {
+ this.type = type;
+ // We're not generating a real timestamp here. It's too expensive.
+ timestamp = -1L;
+ }
+
+ // use this if you care about the timestamp
+ public AbstractEvent(TYPE type, long timestamp) {
+ this.type = type;
+ this.timestamp = timestamp;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public TYPE getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return "EventType: " + getType();
+ }
+}
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AsyncDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AsyncDispatcher.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AsyncDispatcher.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/AsyncDispatcher.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,188 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.event;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Dispatches events in a separate thread. Currently only single thread does
+ * that. Potentially there could be multiple channels for each event type
+ * class and a thread pool can be used to dispatch the events.
+ */
+@SuppressWarnings("rawtypes")
+public class AsyncDispatcher implements Dispatcher {
+
+ private static final Log LOG = LogFactory.getLog(AsyncDispatcher.class);
+
+ private final BlockingQueue<Event> eventQueue;
+ private volatile boolean stopped = false;
+
+ private Thread eventHandlingThread;
+ protected final Map<Class<? extends Enum>, EventHandler> eventDispatchers;
+
+ public AsyncDispatcher() {
+ this(new HashMap<Class<? extends Enum>, EventHandler>(),
+ new LinkedBlockingQueue<Event>());
+ }
+
+ AsyncDispatcher(
+ Map<Class<? extends Enum>, EventHandler> eventDispatchers,
+ BlockingQueue<Event> eventQueue) {
+ this.eventQueue = eventQueue;
+ this.eventDispatchers = eventDispatchers;
+ }
+
+ Runnable createThread() {
+ return new Runnable() {
+ @Override
+ public void run() {
+ while (!stopped && !Thread.currentThread().isInterrupted()) {
+ Event event;
+ try {
+ event = eventQueue.take();
+ } catch(InterruptedException ie) {
+ LOG.info("AsyncDispatcher thread interrupted", ie);
+ return;
+ }
+ if (event != null) {
+ dispatch(event);
+ }
+ }
+ }
+ };
+ }
+
+ public void start() {
+ eventHandlingThread = new Thread(createThread());
+ eventHandlingThread.start();
+ }
+
+ public void stop() {
+ stopped = true;
+ eventHandlingThread.interrupt();
+ try {
+ eventHandlingThread.join();
+ } catch (InterruptedException ie) {
+ LOG.debug("Interruped Exception while stopping", ie);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void dispatch(Event event) {
+ //all events go thru this loop
+ LOG.debug("Dispatching the event " + event.getClass().getName() + "."
+ + event.toString());
+
+ Class<? extends Enum> type = event.getType().getDeclaringClass();
+
+ try{
+ eventDispatchers.get(type).handle(event);
+ }
+ catch (Throwable t) {
+ //TODO Maybe log the state of the queue
+ LOG.fatal("Error in dispatcher thread. Exiting..", t);
+ System.exit(-1);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public void register(Class<? extends Enum> eventType,
+ EventHandler handler) {
+ /* check to see if we have a listener registered */
+ @SuppressWarnings("unchecked")
+ EventHandler<Event> registeredHandler = (EventHandler<Event>)
+ eventDispatchers.get(eventType);
+ LOG.info("Registering " + eventType + " for " + handler.getClass());
+ if (registeredHandler == null) {
+ eventDispatchers.put(eventType, handler);
+ } else if (!(registeredHandler instanceof MultiListenerHandler)){
+ /* for multiple listeners of an event add the multiple listener handler */
+ MultiListenerHandler multiHandler = new MultiListenerHandler();
+ multiHandler.addHandler(registeredHandler);
+ multiHandler.addHandler(handler);
+ eventDispatchers.put(eventType, multiHandler);
+ } else {
+ /* already a multilistener, just add to it */
+ MultiListenerHandler multiHandler
+ = (MultiListenerHandler) registeredHandler;
+ multiHandler.addHandler(handler);
+ }
+ }
+
+ @Override
+ public EventHandler getEventHandler() {
+ return new GenericEventHandler();
+ }
+
+ class GenericEventHandler implements EventHandler<Event> {
+ public void handle(Event event) {
+ /* all this method does is enqueue all the events onto the queue */
+ int qSize = eventQueue.size();
+ if (qSize !=0 && qSize %1000 == 0) {
+ LOG.info("Size of event-queue is " + qSize);
+ }
+ int remCapacity = eventQueue.remainingCapacity();
+ if (remCapacity < 1000) {
+ LOG.info("Very low remaining capacity in the event-queue: "
+ + remCapacity);
+ }
+ try {
+ eventQueue.put(event);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ };
+ }
+
+ /**
+ * Multiplexing an event. Sending it to different handlers that
+ * are interested in the event.
+ * @param <T> the type of event these multiple handlers are interested in.
+ */
+ @SuppressWarnings("rawtypes")
+ static class MultiListenerHandler implements EventHandler<Event> {
+ List<EventHandler<Event>> listofHandlers;
+
+ public MultiListenerHandler() {
+ listofHandlers = new ArrayList<EventHandler<Event>>();
+ }
+
+ @Override
+ public void handle(Event event) {
+ for (EventHandler<Event> handler: listofHandlers) {
+ handler.handle(event);
+ }
+ }
+
+ void addHandler(EventHandler<Event> handler) {
+ listofHandlers.add(handler);
+ }
+
+ }
+}
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Dispatcher.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Dispatcher.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Dispatcher.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Dispatcher.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,32 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.event;
+
+/**
+ * Event Dispatcher interface. It dispatches events to registered
+ * event handlers based on event types.
+ *
+ */
+public interface Dispatcher {
+
+ EventHandler getEventHandler();
+
+ void register(Class<? extends Enum> eventType, EventHandler handler);
+
+}
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Event.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Event.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Event.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/Event.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,30 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.event;
+
+/**
+ * Interface defining events api.
+ *
+ */
+public interface Event<TYPE extends Enum<TYPE>> {
+
+ TYPE getType();
+ long getTimestamp();
+ String toString();
+}
Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/EventHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/EventHandler.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/EventHandler.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/event/EventHandler.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,30 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.event;
+
+/**
+ * Interface for handling events of type T
+ *
+ * @param <T> paremeterized event of type T
+ */
+public interface EventHandler<T extends Event> {
+
+ void handle(T event);
+
+}
Added: incubator/ambari/trunk/client/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/resources/log4j.properties?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/resources/log4j.properties (added)
+++ incubator/ambari/trunk/client/src/main/resources/log4j.properties Thu Sep 22 16:13:55 2011
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=INFO, R
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=${HMS_LOG_DIR}/hms-client.log
+log4j.appender.R.MaxFileSize=10MB
+log4j.appender.R.MaxBackupIndex=10
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d{ISO8601} %p %t %c{1} - %m%n
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.follow=true
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %p %t %c{1} - %m%n
+
Added: incubator/ambari/trunk/client/src/packages/build.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/build.xml?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/build.xml (added)
+++ incubator/ambari/trunk/client/src/packages/build.xml Thu Sep 22 16:13:55 2011
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="hms client packaging">
+ <target name="package-deb">
+ <taskdef name="deb"
+ classname="org.vafer.jdeb.ant.DebAntTask">
+ </taskdef>
+ <mkdir dir="${project.build.directory}/deb/hms-client.control" />
+ <copy todir="${project.build.directory}/deb/hms-client.control">
+ <fileset dir="${basedir}/src/packages/deb/hms-client.control">
+ <exclude name="control" />
+ </fileset>
+ </copy>
+ <copy file="src/packages/deb/hms-client.control/control" todir="${basedir}/target/deb/hms-client.control">
+ <filterchain>
+ <replacetokens>
+ <token key="version" value="${package.version}" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <deb destfile="${project.build.directory}/${artifactId}_${package.version}-${package.release}_${os.arch}.deb" control="${basedir}/target/deb/hms-client.control">
+ <data src="${project.build.directory}/${final.name}.tar.gz">
+ <mapper type="prefix" strip="1" prefix="${package.prefix}/share/hms" />
+ <exclude name="${final.name}/conf" />
+ <exclude name="${final.name}/conf/*" />
+ <include name="**" />
+ </data>
+ <tarfileset dir="${basedir}/src/packages" filemode="755" prefix="${package.prefix}/share/hms/sbin">
+ <exclude name=".svn" />
+ <include name="*.sh" />
+ </tarfileset>
+ <tarfileset dir="${basedir}/src/packages/deb/init.d" filemode="755" prefix="${package.prefix}/share/hms/sbin">
+ <exclude name=".svn" />
+ <include name="**" />
+ </tarfileset>
+ </deb>
+ </target>
+
+ <target name="package-rpm">
+ <delete dir="${project.build.directory}/rpm/hms/buildroot" />
+ <mkdir dir="${project.build.directory}/rpm/hms/SOURCES" />
+ <mkdir dir="${project.build.directory}/rpm/hms/BUILD" />
+ <mkdir dir="${project.build.directory}/rpm/hms/RPMS" />
+ <mkdir dir="${project.build.directory}/rpm/hms/buildroot" />
+ <copy file="${project.build.directory}/${final.name}.tar.gz" todir="${project.build.directory}/rpm/hms/SOURCES" />
+ <copy file="src/packages/rpm/spec/hms-client.spec" todir="target/rpm/hms/SPECS">
+ <filterchain>
+ <replacetokens>
+ <token key="final.name" value="${final.name}" />
+ <token key="version" value="${package.version}" />
+ <token key="package.name" value="${final.name}.tar.gz" />
+ <token key="package.release" value="${package.release}" />
+ <token key="package.build.dir" value="${project.build.directory}/rpm/hms/BUILD" />
+ <token key="package.prefix" value="${package.prefix}" />
+ <token key="package.conf.dir" value="${package.conf.dir}" />
+ <token key="package.log.dir" value="${package.log.dir}" />
+ <token key="package.pid.dir" value="${package.pid.dir}" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <rpm specFile="hms-client.spec" command="-bb" topDir="${project.build.directory}/rpm/hms" cleanBuildDir="true" failOnError="true"/>
+ <copy todir="${project.build.directory}" flatten="true">
+ <fileset dir="${project.build.directory}/rpm/hms/RPMS">
+ <include name="**/*.rpm" />
+ </fileset>
+ </copy>
+ <delete dir="${project.build.directory}/rpm" />
+ </target>
+
+</project>
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/conffile
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/conffile?rev=1174242&view=auto
==============================================================================
(empty)
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/control
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/control?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/deb/hms-client.control/control (added)
+++ incubator/ambari/trunk/client/src/packages/deb/hms-client.control/control Thu Sep 22 16:13:55 2011
@@ -0,0 +1,9 @@
+Package: hms-client
+Version: @version@
+Section: misc
+Priority: optional
+Architecture: all
+Depends: openjdk-6-jre-headless
+Maintainer: Apache Software Foundation <hm...@incubator.apache.org>
+Description: HMS Client
+Distribution: development
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postinst
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postinst?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postinst (added)
+++ incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postinst Thu Sep 22 16:13:55 2011
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+bash /usr/share/hbase/sbin/update-hms-client-env.sh \
+ --prefix=/usr \
+ --bin-dir=/usr/bin \
+ --conf-dir=/etc/hms \
+ --log-dir=/var/log/hms \
+ --pid-dir=/var/run/hms
+
Propchange: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postinst
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postrm
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postrm?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postrm (added)
+++ incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postrm Thu Sep 22 16:13:55 2011
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+exit 0
+
Propchange: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/postrm
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/preinst
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/preinst?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/deb/hms-client.control/preinst (added)
+++ incubator/ambari/trunk/client/src/packages/deb/hms-client.control/preinst Thu Sep 22 16:13:55 2011
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
Propchange: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/preinst
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/prerm
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/deb/hms-client.control/prerm?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/deb/hms-client.control/prerm (added)
+++ incubator/ambari/trunk/client/src/packages/deb/hms-client.control/prerm Thu Sep 22 16:13:55 2011
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+bash /usr/share/hbase/sbin/update-hms-client-env.sh \
+ --prefix=/usr \
+ --bin-dir=/usr/bin \
+ --conf-dir=/etc/hms \
+ --log-dir=/var/log/hms \
+ --pid-dir=/var/run/hms \
+ --uninstal
+
Propchange: incubator/ambari/trunk/client/src/packages/deb/hms-client.control/prerm
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/client/src/packages/rpm/spec/hms-client.spec
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/rpm/spec/hms-client.spec?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/rpm/spec/hms-client.spec (added)
+++ incubator/ambari/trunk/client/src/packages/rpm/spec/hms-client.spec Thu Sep 22 16:13:55 2011
@@ -0,0 +1,129 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# RPM Spec file for HBase version @version@
+#
+
+%define name hms-client
+%define version @version@
+%define release @package.release@
+
+# Installation Locations
+%define _source @package.name@
+%define _final_name @final.name@
+%define _prefix @package.prefix@
+%define _bin_dir %{_prefix}/bin
+%define _conf_dir @package.conf.dir@
+%define _include_dir %{_prefix}/include
+%define _lib_dir %{_prefix}/lib
+%define _lib64_dir %{_prefix}/lib64
+%define _libexec_dir %{_prefix}/libexec
+%define _log_dir @package.log.dir@
+%define _man_dir %{_prefix}/man
+%define _pid_dir @package.pid.dir@
+%define _sbin_dir %{_prefix}/sbin
+%define _share_dir %{_prefix}/share/hms
+%define _src_dir %{_prefix}/src
+%define _var_dir %{_prefix}/var/lib
+
+# Build time settings
+%define _build_dir @package.build.dir@
+%define _final_name @final.name@
+%define debug_package %{nil}
+
+Summary: Hadoop Management System Client
+License: Apache License, Version 2.0
+URL: http://incubator.apache.org/hms
+Vendor: Apache Software Foundation
+Group: Development/Libraries
+Name: %{name}
+Version: %{version}
+Release: %{release}
+Source0: %{_source}
+Prefix: %{_prefix}
+Prefix: %{_conf_dir}
+Prefix: %{_log_dir}
+Prefix: %{_pid_dir}
+Buildroot: %{_build_dir}
+Requires: sh-utils, textutils, /usr/sbin/useradd, /usr/sbin/usermod, /sbin/chkconfig, /sbin/service, jdk >= 1.6, hadoop
+AutoReqProv: no
+Provides: hms-client
+
+%description
+Hadoop Management System Agent manage software installation and configuration for Hadoop software stack.
+
+%prep
+%setup -n %{_final_name}
+
+%build
+if [ -d ${RPM_BUILD_DIR}%{_prefix} ]; then
+ rm -rf ${RPM_BUILD_DIR}%{_prefix}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_log_dir} ]; then
+ rm -rf ${RPM_BUILD_DIR}%{_log_dir}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_conf_dir} ]; then
+ rm -rf ${RPM_BUILD_DIR}%{_conf_dir}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_pid_dir} ]; then
+ rm -rf ${RPM_BUILD_DIR}%{_pid_dir}
+fi
+
+mkdir -p ${RPM_BUILD_DIR}%{_conf_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_bin_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_include_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_lib_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_libexec_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_log_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_conf_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_man_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_pid_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_sbin_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_share_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_src_dir}
+
+cp ${RPM_BUILD_DIR}/%{_final_name}/src/packages/update-hms-client-env.sh ${RPM_BUILD_DIR}/%{_final_name}/sbin/update-hms-client-env.sh
+chmod 0755 ${RPM_BUILD_DIR}/%{_final_name}/sbin/*
+mv -f ${RPM_BUILD_DIR}/%{_final_name}/* ${RPM_BUILD_DIR}%{_share_dir}
+
+rm -rf ${RPM_BUILD_DIR}/%{_final_name}
+
+%preun
+${RPM_INSTALL_PREFIX0}/share/hms/sbin/update-hms-client-env.sh \
+ --prefix=${RPM_INSTALL_PREFIX0} \
+ --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+ --conf-dir=${RPM_INSTALL_PREFIX1} \
+ --log-dir=${RPM_INSTALL_PREFIX2} \
+ --pid-dir=${RPM_INSTALL_PREFIX3} \
+ --uninstall
+
+%pre
+
+%post
+${RPM_INSTALL_PREFIX0}/share/hms/sbin/update-hms-client-env.sh \
+ --prefix=${RPM_INSTALL_PREFIX0} \
+ --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+ --conf-dir=${RPM_INSTALL_PREFIX1} \
+ --log-dir=${RPM_INSTALL_PREFIX2} \
+ --pid-dir=${RPM_INSTALL_PREFIX3}
+
+%files
+%defattr(-,root,root)
+%{_prefix}
+%config %{_conf_dir}
Added: incubator/ambari/trunk/client/src/packages/tarball/all.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/tarball/all.xml?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/tarball/all.xml (added)
+++ incubator/ambari/trunk/client/src/packages/tarball/all.xml Thu Sep 22 16:13:55 2011
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
+ <!--This 'all' id is not appended to the produced bundle because we do this:
+ http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#required-classifiers
+ -->
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>${basedir}/*.txt</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src</directory>
+ </fileSet>
+ <fileSet>
+ <directory>conf</directory>
+ </fileSet>
+ <fileSet>
+ <directory>../bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>${artifactId}-${project.version}.jar</include>
+ <include>${artifactId}-${project.version}-tests.jar</include>
+ <include>VERSION</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/site</directory>
+ <outputDirectory>docs</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/packages</directory>
+ <outputDirectory>sbin</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>update-hms-${artifactId}-env.sh</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+</assembly>
Added: incubator/ambari/trunk/client/src/packages/update-hms-client-env.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/packages/update-hms-client-env.sh?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/packages/update-hms-client-env.sh (added)
+++ incubator/ambari/trunk/client/src/packages/update-hms-client-env.sh Thu Sep 22 16:13:55 2011
@@ -0,0 +1,170 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This script configures hms-client-env.sh and symlinkis directories for
+# relocating RPM locations.
+
+usage() {
+ echo "
+usage: $0 <parameters>
+ Required parameters:
+ --prefix=PREFIX path to install into
+
+ Optional parameters:
+ --arch=i386 OS Architecture
+ --bin-dir=PREFIX/bin Executable directory
+ --conf-dir=/etc/hms Configuration directory
+ --log-dir=/var/log/hms Log directory
+ --pid-dir=/var/run PID file location
+ "
+ exit 1
+}
+
+OPTS=$(getopt \
+ -n $0 \
+ -o '' \
+ -l 'arch:' \
+ -l 'prefix:' \
+ -l 'bin-dir:' \
+ -l 'conf-dir:' \
+ -l 'lib-dir:' \
+ -l 'log-dir:' \
+ -l 'pid-dir:' \
+ -l 'uninstall' \
+ -- "$@")
+
+if [ $? != 0 ] ; then
+ usage
+fi
+
+eval set -- "${OPTS}"
+while true ; do
+ case "$1" in
+ --arch)
+ ARCH=$2 ; shift 2
+ ;;
+ --prefix)
+ PREFIX=$2 ; shift 2
+ ;;
+ --bin-dir)
+ BIN_DIR=$2 ; shift 2
+ ;;
+ --log-dir)
+ LOG_DIR=$2 ; shift 2
+ ;;
+ --lib-dir)
+ LIB_DIR=$2 ; shift 2
+ ;;
+ --conf-dir)
+ CONF_DIR=$2 ; shift 2
+ ;;
+ --pid-dir)
+ PID_DIR=$2 ; shift 2
+ ;;
+ --uninstall)
+ UNINSTALL=1; shift
+ ;;
+ --)
+ shift ; break
+ ;;
+ *)
+ echo "Unknown option: $1"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+for var in PREFIX; do
+ if [ -z "$(eval "echo \$$var")" ]; then
+ echo Missing param: $var
+ usage
+ fi
+done
+
+ARCH=${ARCH:-i386}
+BIN_DIR=${BIN_DIR:-$PREFIX/share/hms/bin}
+CONF_DIR=${CONF_DIR:-$PREFIX/conf}
+LIB_DIR=${LIB_DIR:-$PREFIX/lib}
+LOG_DIR=${LOG_DIR:-$PREFIX/var/log}
+PID_DIR=${PID_DIR:-$PREFIX/var/run}
+UNINSTALL=${UNINSTALL:-0}
+
+if [ "${ARCH}" != "i386" ]; then
+ LIB_DIR=${LIB_DIR}64
+fi
+
+if [ "${UNINSTALL}" -eq "1" ]; then
+ # Remove symlinks
+ if [ "${BIN_DIR}" != "${PREFIX}/share/hms/bin" ]; then
+ for var in `ls ${PREFIX}/share/hms/bin`; do
+ rm -f ${BIN_DIR}/${var}
+ done
+ fi
+ if [ -f /etc/default/hms-client-env.sh ]; then
+ rm -f /etc/default/hms-client-env.sh
+ fi
+ if [ "${CONF_DIR}" != "${PREFIX}/share/hms/conf" ]; then
+ rm -f ${PREFIX}/share/hms/conf
+ fi
+
+ rm -f ${PREFIX}/share/hms/sbin/hms-client
+
+else
+ # Create symlinks
+ if [ "${BIN_DIR}" != "${PREFIX}/share/hms/bin" ]; then
+ for var in `ls ${PREFIX}/share/hms/bin`; do
+ ln -sf ${PREFIX}/share/hms/bin/${var} ${BIN_DIR}/${var}
+ done
+ fi
+ if [ "${CONF_DIR}" != "${PREFIX}/share/hms/conf" ]; then
+ ln -sf ${CONF_DIR} ${PREFIX}/share/hms/conf
+ fi
+
+ chmod 755 ${PREFIX}/share/hms/sbin/*
+
+ ln -sf ${CONF_DIR}/hms-client-env.sh /etc/default/hms-client-env.sh
+
+ mkdir -p ${PID_DIR}
+ mkdir -p ${LOG_DIR}
+
+ TFILE="/tmp/$(basename $0).$$.tmp"
+ grep -v "^export HMS_HOME" ${CONF_DIR}/hms-client-env.sh | \
+ grep -v "^export HMS_CONF_DIR" | \
+ grep -v "^export HMS_CLASSPATH" | \
+ grep -v "^export HMS_PID_DIR" | \
+ grep -v "^export HMS_LOG_DIR" | \
+ grep -v "^export JAVA_HOME" > ${TFILE}
+ if [ -z "${JAVA_HOME}" ]; then
+ if [ -e /etc/lsb-release ]; then
+ JAVA_HOME=`update-alternatives --config java | grep java | cut -f2 -d':' | cut -f2 -d' ' | sed -e 's/\/bin\/java//'`
+ else
+ JAVA_HOME=/usr/java/default
+ fi
+ fi
+ if [ "${JAVA_HOME}xxx" != "xxx" ]; then
+ echo "export JAVA_HOME=${JAVA_HOME}" >> ${TFILE}
+ fi
+ echo "export HMS_IDENT_STRING=\`whoami\`" >> ${TFILE}
+ echo "export HMS_HOME=${PREFIX}/share/hms" >> ${TFILE}
+ echo "export HMS_CONF_DIR=${CONF_DIR}" >> ${TFILE}
+ echo "export HMS_CLASSPATH=${CONF_DIR}:${HADOOP_CONF_DIR}:${HADOOP_JARS}:${ZOOKEEPER_JARS}" >> ${TFILE}
+ echo "export HMS_PID_DIR=${PID_DIR}" >> ${TFILE}
+ echo "export HMS_LOG_DIR=${LOG_DIR}" >> ${TFILE}
+ cp ${TFILE} ${CONF_DIR}/hms-client-env.sh
+ rm -f ${TFILE}
+fi
Added: incubator/ambari/trunk/conf/hms-env.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/conf/hms-env.sh?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/conf/hms-env.sh (added)
+++ incubator/ambari/trunk/conf/hms-env.sh Thu Sep 22 16:13:55 2011
@@ -0,0 +1,59 @@
+#
+#/**
+# * Copyright 2007 The Apache Software Foundation
+# *
+# * Licensed to the Apache Software Foundation (ASF) under one
+# * or more contributor license agreements. See the NOTICE file
+# * distributed with this work for additional information
+# * regarding copyright ownership. The ASF licenses this file
+# * to you under the Apache License, Version 2.0 (the
+# * "License"); you may not use this file except in compliance
+# * with the License. You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+# Set environment variables here.
+
+# The java implementation to use. Java 1.6 required.
+# export JAVA_HOME=/usr/java/default/
+
+# Extra Java CLASSPATH elements. Optional.
+# export HMS_CLASSPATH=
+
+# The maximum amount of heap to use, in MB. Default is 64.
+export HMS_AGENT_HEAPSIZE=64
+
+# Extra Java runtime options.
+# Below are what we set by default. May only work with SUN JVM.
+# For more on why as well as other possible settings,
+# see http://wiki.apache.org/hadoop/PerformanceTuning
+# export HMS_OPTS="-ea -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode"
+
+# Uncomment below to enable java garbage collection logging.
+# export HMS_OPTS="$HMS_OPTS -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$HMS_HOME/logs/gc-hms-agent.log"
+
+# Uncomment and adjust to enable JMX exporting
+# See jmxremote.password and jmxremote.access in $JRE_HOME/lib/management to configure remote password access.
+# More details at: http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
+#
+# export HMS_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
+
+# Where log files are stored. $HMS_HOME/logs by default.
+# export HMS_LOG_DIR=${HMS_HOME}/logs
+
+# A string representing this instance of hms agent. $USER by default.
+# export HMS_IDENT_STRING=agent
+
+# The scheduling priority for daemon processes. See 'man nice'.
+# export HMS_NICENESS=10
+
+# The directory where pid files are stored. /tmp by default.
+# export HMS_PID_DIR=/var/run/
+
Added: incubator/ambari/trunk/controller/bin/hms-daemon.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/bin/hms-daemon.sh?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/bin/hms-daemon.sh (added)
+++ incubator/ambari/trunk/controller/bin/hms-daemon.sh Thu Sep 22 16:13:55 2011
@@ -0,0 +1,199 @@
+#!/usr/bin/env bash
+#
+#/**
+# * Copyright 2007 The Apache Software Foundation
+# *
+# * Licensed to the Apache Software Foundation (ASF) under one
+# * or more contributor license agreements. See the NOTICE file
+# * distributed with this work for additional information
+# * regarding copyright ownership. The ASF licenses this file
+# * to you under the Apache License, Version 2.0 (the
+# * "License"); you may not use this file except in compliance
+# * with the License. You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+#
+# Runs a Hadoop hms command as a daemon.
+#
+# Environment Variables
+#
+# HMS_CONF_DIR Alternate hms conf dir. Default is ${HMS_HOME}/conf.
+# HMS_LOG_DIR Where log files are stored. PWD by default.
+# HMS_PID_DIR The pid files are stored. /tmp by default.
+# HMS_IDENT_STRING A string representing this instance of hadoop. $USER by default
+# HMS_NICENESS The scheduling priority for daemons. Defaults to 0.
+#
+# Modelled after $HADOOP_HOME/bin/hadoop-daemon.sh
+
+usage="Usage: hms-daemon.sh [--config <conf-dir>]\
+ (start|stop|restart) <hms-command> \
+ <args...>"
+
+# if no args specified, show usage
+if [ $# -le 1 ]; then
+ echo $usage
+ exit 1
+fi
+
+bin=`dirname "${BASH_SOURCE-$0}"`
+bin=`cd "$bin">/dev/null; pwd`
+
+. "$bin"/hms-config.sh
+
+# get arguments
+startStop=$1
+shift
+
+command=$1
+shift
+
+hms_rotate_log ()
+{
+ log=$1;
+ num=5;
+ if [ -n "$2" ]; then
+ num=$2
+ fi
+ if [ -f "$log" ]; then # rotate logs
+ while [ $num -gt 1 ]; do
+ prev=`expr $num - 1`
+ [ -f "$log.$prev" ] && mv -f "$log.$prev" "$log.$num"
+ num=$prev
+ done
+ mv -f "$log" "$log.$num";
+ fi
+}
+
+wait_until_done ()
+{
+ p=$1
+ cnt=${HMS_SLAVE_TIMEOUT:-300}
+ origcnt=$cnt
+ while kill -0 $p > /dev/null 2>&1; do
+ if [ $cnt -gt 1 ]; then
+ cnt=`expr $cnt - 1`
+ sleep 1
+ else
+ echo "Process did not complete after $origcnt seconds, killing."
+ kill -9 $p
+ exit 1
+ fi
+ done
+ return 0
+}
+
+# get log directory
+if [ "$HMS_LOG_DIR" = "" ]; then
+ export HMS_LOG_DIR="$HMS_HOME/logs"
+fi
+mkdir -p "$HMS_LOG_DIR"
+
+if [ "$HMS_PID_DIR" = "" ]; then
+ HMS_PID_DIR=/tmp
+fi
+
+if [ "$HMS_IDENT_STRING" = "" ]; then
+ export HMS_IDENT_STRING="$USER"
+fi
+
+# Some variables
+# Work out java location so can print version into log.
+if [ "$JAVA_HOME" != "" ]; then
+ #echo "run java in $JAVA_HOME"
+ JAVA_HOME=$JAVA_HOME
+fi
+if [ "$JAVA_HOME" = "" ]; then
+ echo "Error: JAVA_HOME is not set."
+ exit 1
+fi
+JAVA=$JAVA_HOME/bin/java
+export HMS_LOGFILE=hms-$HMS_IDENT_STRING-$command-$HOSTNAME.log
+export HMS_ROOT_LOGGER="INFO,DRFA"
+logout=$HMS_LOG_DIR/hms-$HMS_IDENT_STRING-$command-$HOSTNAME.out
+loglog="${HMS_LOG_DIR}/${HMS_LOGFILE}"
+pid=$HMS_PID_DIR/hms-$HMS_IDENT_STRING-$command.pid
+
+# Set default scheduling priority
+if [ "$HMS_NICENESS" = "" ]; then
+ export HMS_NICENESS=0
+fi
+
+case $startStop in
+
+ (start)
+ mkdir -p "$HMS_PID_DIR"
+ if [ -f $pid ]; then
+ if kill -0 `cat $pid` > /dev/null 2>&1; then
+ echo $command running as process `cat $pid`. Stop it first.
+ exit 1
+ fi
+ fi
+
+ hms_rotate_log $logout
+ echo starting $command, logging to $logout
+ # Add to the command log file vital stats on our environment.
+ echo "`date` Starting $command on `hostname`" >> $loglog
+ echo "ulimit -n `ulimit -n`" >> $loglog 2>&1
+ nohup nice -n $HMS_NICENESS "$HMS_HOME"/bin/hms \
+ --config "${HMS_CONF_DIR}" \
+ $command $startStop "$@" > "$logout" 2>&1 < /dev/null &
+ echo $! > $pid
+ sleep 1; head "$logout"
+ ;;
+
+ (stop)
+ if [ -f $pid ]; then
+ # kill -0 == see if the PID exists
+ if kill -0 `cat $pid` > /dev/null 2>&1; then
+ echo -n stopping $command
+ if [ "$command" = "master" ]; then
+ echo "`date` Killing $command" >> $loglog
+ kill -9 `cat $pid` > /dev/null 2>&1
+ else
+ echo "`date` Killing $command" >> $loglog
+ kill `cat $pid` > /dev/null 2>&1
+ fi
+ while kill -0 `cat $pid` > /dev/null 2>&1; do
+ echo -n "."
+ sleep 1;
+ done
+ rm $pid
+ echo
+ else
+ retval=$?
+ echo no $command to stop because kill -0 of pid `cat $pid` failed with status $retval
+ fi
+ else
+ echo no $command to stop because no pid file $pid
+ fi
+ ;;
+
+ (restart)
+ thiscmd=$0
+ args=$@
+ # stop the command
+ $thiscmd --config "${HMS_CONF_DIR}" stop $command $args &
+ wait_until_done $!
+ # wait a user-specified sleep period
+ sp=${HMS_RESTART_SLEEP:-3}
+ if [ $sp -gt 0 ]; then
+ sleep $sp
+ fi
+ # start the command
+ $thiscmd --config "${HMS_CONF_DIR}" start $command $args &
+ wait_until_done $!
+ ;;
+
+ (*)
+ echo $usage
+ exit 1
+ ;;
+
+esac
Propchange: incubator/ambari/trunk/controller/bin/hms-daemon.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/controller/conf/ambari-env.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/conf/ambari-env.sh?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/conf/ambari-env.sh (added)
+++ incubator/ambari/trunk/controller/conf/ambari-env.sh Thu Sep 22 16:13:55 2011
@@ -0,0 +1,2 @@
+JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
+AMBARI_PID_DIR=/tmp
Added: incubator/ambari/trunk/controller/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/pom.xml?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/pom.xml (added)
+++ incubator/ambari/trunk/controller/pom.xml Thu Sep 22 16:13:55 2011
@@ -0,0 +1,30 @@
+<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">
+
+ <parent>
+ <groupId>org.apache.ambari</groupId>
+ <artifactId>ambari</artifactId>
+ <version>0.1.0</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ambari</groupId>
+ <artifactId>ambari-controller</artifactId>
+ <packaging>jar</packaging>
+ <name>controller</name>
+ <version>0.1.0-SNAPSHOT</version>
+ <description>Ambari Controller</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ambari</groupId>
+ <artifactId>ambari-client</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.6</version>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.controller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.ambari.common.util.DaemonWatcher;
+import org.apache.ambari.common.util.ExceptionUtil;
+
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+public class Controller {
+ private static Log LOG = LogFactory.getLog(Controller.class);
+ public static int CONTROLLER_PORT = 4080;
+ private static Controller instance = new Controller();
+ private Server server = null;
+ public volatile boolean running = true; // true while controller runs
+
+ public static Controller getInstance() {
+ return instance;
+ }
+
+ public void run() {
+
+ server = new Server(CONTROLLER_PORT);
+
+ try {
+ Context root = new Context(server, "/", Context.SESSIONS);
+ /*
+ String AMBARI_HOME = System.getenv("AMBARI_HOME");
+ root.setBaseResource(new ResourceCollection(new Resource[]
+ {
+ Resource.newResource(AMBARI_HOME+"/webapps/")
+ }));
+ */
+ ServletHolder rootServlet = root.addServlet(DefaultServlet.class, "/");
+ rootServlet.setInitOrder(1);
+
+ ServletHolder sh = new ServletHolder(ServletContainer.class);
+ sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
+ sh.setInitParameter("com.sun.jersey.config.property.packages", "org.apache.ambari.controller.rest.resources");
+ root.addServlet(sh, "/*");
+ sh.setInitOrder(2);
+ server.setStopAtShutdown(true);
+ server.start();
+ } catch (Exception e) {
+ LOG.error(ExceptionUtil.getStackTrace(e));
+ }
+ }
+
+ public void stop() throws Exception {
+ try {
+ server.stop();
+ } catch (Exception e) {
+ LOG.error(ExceptionUtil.getStackTrace(e));
+ }
+ }
+
+ public static void main(String[] args) {
+ //DaemonWatcher.createInstance(System.getProperty("PID"), 9100);
+ try {
+ Controller controller = Controller.getInstance();
+ if (controller != null) {
+ controller.run();
+ }
+ } catch(Throwable t) {
+ DaemonWatcher.bailout(1);
+ }
+ }
+}
Propchange: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.controller.rest.config;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.api.json.JSONJAXBContext;
+
+@Provider
+public class ContextProvider implements ContextResolver<JAXBContext> {
+
+ private JAXBContext context;
+ private Class[] types = { };
+
+ public ContextProvider() throws Exception {
+ this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), types);
+ }
+
+ public JAXBContext getContext(Class<?> objectType) {
+ for (Class type : types) {
+ if (type.equals(objectType))
+ return context;
+ }
+ return null;
+ }
+}
\ No newline at end of file
Propchange: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/config/ContextProvider.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintResource.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintResource.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintResource.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,102 @@
+package org.apache.ambari.controller.rest.resources;
+
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+
+import org.apache.ambari.common.rest.entities.Blueprint;
+
+/** BlueprintResource represents a Hadoop blueprint to be installed on a
+ * cluster. Blueprints define a collection of Hadoop components that are
+ * installed together on a cluster and their configuration.
+ */
+@Path(value = "/blueprints/{blueprintName}")
+public class BlueprintResource {
+
+ /** Get a blueprint
+ *
+ * <p>
+ * REST:<br>
+ * URL Path : /blueprints/{blueprintName}<br>
+ * HTTP Method : GET <br>
+ * HTTP Request Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * HTTP Response Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * <p>
+ *
+ * @param blueprintName Name of the blueprint
+ * @param revision The optional blueprint revision to get
+ * @return blueprint definition
+ * @throws Exception throws Exception (TBD)
+ */
+ @GET
+ @Produces({"application/json", "application/xml"})
+ public Blueprint getBlueprint(@PathParam("blueprintName") String blueprintName,
+ @QueryParam("revision") int revision) throws Exception {
+ return null;
+ }
+
+ /*
+ * Delete blueprint
+ */
+ /** Delete the blueprint
+ *
+ * <p>
+ * REST:<br>
+ * URL Path : /blueprints/{blueprintName}<br>
+ * HTTP Method : DELETE <br>
+ * HTTP Request Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * HTTP Response Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * <p>
+ *
+ * @param stackName Name of the Hadoop stack
+ * @throws Exception throws Exception (TBD)
+ */
+ @DELETE
+ @Consumes({"application/json", "application/xml"})
+ public void deleteBlueprint(@PathParam("blueprintName") String blueprintName) throws Exception {
+ }
+
+ /** Update a current blueprint.
+ * <p>
+ * Updates a current blueprint to update some of its fields.
+ * <p>
+ * REST:<br>
+ * URL Path : /blueprints/{blueprintName}<br>
+ * HTTP Method : PUT <br>
+ * HTTP Request Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * HTTP Response Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * <p>
+ *
+ * @param blueprintName Name of the blueprint
+ * @param blueprint Input blueprint object specifying the blueprint definition
+ * @return Returns the new revision of the blueprint
+ * @throws Exception throws Exception
+ */
+ @Path(value = "/blueprints/{blueprintName}")
+ @PUT
+ @Consumes
+ public Blueprint updateBlueprint(@PathParam("blueprintName") String blueprintName, Blueprint blueprint) throws Exception {
+ return null;
+ }
+
+}
Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java?rev=1174242&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java Thu Sep 22 16:13:55 2011
@@ -0,0 +1,71 @@
+package org.apache.ambari.controller.rest.resources;
+
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+
+import org.apache.ambari.common.rest.entities.Blueprint;
+
+/** BlueprintResource represents a Hadoop blueprint to be installed on a
+ * cluster. Blueprints define a collection of Hadoop components that are
+ * installed together on a cluster and their configuration.
+ */
+@Path(value = "/blueprints")
+public class BlueprintsResource {
+
+ /** Creates a new blueprint.
+ * <p>
+ * If named blueprint does not exists already, then it creates new one i.e. revision zero.
+ * <p>
+ * REST:<br>
+ * URL Path : /blueprints/<br>
+ * HTTP Method : POST <br>
+ * HTTP Request Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * HTTP Response Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * <p>
+ *
+ * @param blueprint Input blueprint object specifying the blueprint definition
+ * @return Returns the newly created revision of the blueprint
+ * @throws Exception throws Exception
+ */
+ @POST
+ @Consumes
+ public Blueprint createBlueprint(Blueprint blueprint) throws Exception {
+ return null;
+ }
+
+ /** Get the list of blueprint names
+ * <p>
+ * REST:<br>
+ * URL Path : /blueprints<br>
+ * HTTP Method : GET <br>
+ * HTTP Request Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * HTTP Response Header : <br>
+ * Content-type = application/json <br>
+ * Accept = application/json <br>
+ * <p>
+ *
+ * @return Returns the list of blueprint names
+ * @throws Exception throws Exception
+ */
+ @GET
+ @Consumes
+ public List<String> listBlueprints() throws Exception {
+ return null;
+ }
+
+}