From 9872f074dedde7541bae8f04e874676cad4843a3 Mon Sep 17 00:00:00 2001 From: David Nalley Date: Wed, 25 Jan 2012 03:00:36 -0500 Subject: [PATCH] just a few more whitespace issues --- agent/src/com/cloud/agent/Agent.java | 26 +++++----- agent/src/com/cloud/agent/AgentShell.java | 18 +++---- agent/src/com/cloud/agent/IAgentShell.java | 8 ++-- .../AgentComponentLibraryBase.java | 12 ++--- .../agent/dao/impl/PropertiesStorage.java | 18 +++---- .../cloud/agent/dhcp/DhcpPacketParser.java | 38 +++++++-------- .../agent/dhcp/DhcpProtocolParserServer.java | 2 +- .../src/com/cloud/agent/dhcp/DhcpSnooper.java | 12 ++--- .../com/cloud/agent/dhcp/DhcpSnooperImpl.java | 48 +++++++++---------- .../com/cloud/agent/dhcp/FakeDhcpSnooper.java | 2 +- 10 files changed, 92 insertions(+), 92 deletions(-) diff --git a/agent/src/com/cloud/agent/Agent.java b/agent/src/com/cloud/agent/Agent.java index 3508e881418..521799f123a 100755 --- a/agent/src/com/cloud/agent/Agent.java +++ b/agent/src/com/cloud/agent/Agent.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -10,10 +10,10 @@ * 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 . - * + * */ package com.cloud.agent; @@ -77,9 +77,9 @@ import com.cloud.utils.script.Script; * || host | host to connect to | ip address | localhost || * || port | port to connect to | port number | 8250 || * || instance | Used to allow multiple agents running on the same host | String | none || * } - * + * * For more configuration options, see the individual types. - * + * **/ public class Agent implements HandlerFactory, IAgentControl { private static final Logger s_logger = Logger.getLogger(Agent.class.getName()); @@ -132,8 +132,8 @@ public class Agent implements HandlerFactory, IAgentControl { _connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this); Runtime.getRuntime().addShutdownHook(new ShutdownThread(this)); - - _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, + + _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue(), new NamedThreadFactory("UgentTask") ); } @@ -167,10 +167,10 @@ public class Agent implements HandlerFactory, IAgentControl { s_logger.debug("Adding shutdown hook"); Runtime.getRuntime().addShutdownHook(new ShutdownThread(this)); - _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, + _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue(), new NamedThreadFactory("UgentTask") ); - + s_logger.info("Agent [id = " + (_id != null ? _id : "new") + " : type = " + getResourceName() + " : zone = " + _shell.getZone() + " : pod = " + _shell.getPod() + " : workers = " + _shell.getWorkers() + " : host = " + _shell.getHost() + " : port = " + _shell.getPort()); } @@ -265,7 +265,7 @@ public class Agent implements HandlerFactory, IAgentControl { _resource.stop(); _resource = null; } - + _ugentTaskPool.shutdownNow(); } @@ -435,9 +435,9 @@ public class Agent implements HandlerFactory, IAgentControl { setLastPingResponseTime(); scheduleWatch(link, response, _pingInterval, _pingInterval); - + _ugentTaskPool.setKeepAliveTime(2* _pingInterval, TimeUnit.MILLISECONDS); - + s_logger.info("Startup Response Received: agent id = " + getId()); } diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index c33af22caa3..93d7281093c 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -10,10 +10,10 @@ * 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 . - * + * */ package com.cloud.agent; @@ -118,7 +118,7 @@ public class AgentShell implements IAgentShell { public String getHost() { return _host; } - + @Override public String getPrivateIp() { return _privateIp; @@ -378,7 +378,7 @@ public class AgentShell implements IAgentShell { _storage.configure("Storage", new HashMap()); } - + // merge with properties from command line to let resource access command line parameters for(Map.Entry cmdLineProp : getCmdLineProperties().entrySet()) { _properties.put(cmdLineProp.getKey(), cmdLineProp.getValue()); @@ -539,10 +539,10 @@ public class AgentShell implements IAgentShell { } else { instance += "."; } - + String pidDir = getProperty(null, "piddir"); - - + + final String run = "agent." + instance + "pid"; s_logger.debug("Checking to see if " + run + "exists."); ProcessUtil.pidCheck(pidDir, run); diff --git a/agent/src/com/cloud/agent/IAgentShell.java b/agent/src/com/cloud/agent/IAgentShell.java index f622a463f38..a3fd21d0c73 100644 --- a/agent/src/com/cloud/agent/IAgentShell.java +++ b/agent/src/com/cloud/agent/IAgentShell.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -10,10 +10,10 @@ * 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 . - * + * */ package com.cloud.agent; diff --git a/agent/src/com/cloud/agent/configuration/AgentComponentLibraryBase.java b/agent/src/com/cloud/agent/configuration/AgentComponentLibraryBase.java index b481f438684..56b1b89b749 100755 --- a/agent/src/com/cloud/agent/configuration/AgentComponentLibraryBase.java +++ b/agent/src/com/cloud/agent/configuration/AgentComponentLibraryBase.java @@ -1,7 +1,7 @@ /** * Copyright (C) 2011 Cloud.com. All rights reserved. * - * This software is licensed under the GNU General Public License v3 or later. + * This software is licensed under the GNU General Public License v3 or later. * * It is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,17 +55,17 @@ public class AgentComponentLibraryBase extends ComponentLibraryBase { public Map, Class> getFactories() { return null; } - + protected void populateManagers() { //addManager("StackMaidManager", StackMaidManagerImpl.class); } - + protected void populateAdapters() { - + } - + protected void populateServices() { - + } @Override diff --git a/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java b/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java index 2a925da7bd4..bccee7ffabd 100755 --- a/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java +++ b/agent/src/com/cloud/agent/dao/impl/PropertiesStorage.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -10,10 +10,10 @@ * 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 . - * + * */ package com.cloud.agent.dao.impl; @@ -34,7 +34,7 @@ import com.cloud.utils.PropertiesUtil; /** * Uses Properties to implement storage. - * + * * @config * {@table * || Param Name | Description | Values | Default || @@ -47,7 +47,7 @@ public class PropertiesStorage implements StorageComponent { Properties _properties = new Properties(); File _file; String _name; - + @Override public synchronized String get(String key) { return _properties.getProperty(key); @@ -84,7 +84,7 @@ public class PropertiesStorage implements StorageComponent { if (path == null) { path = "agent.properties"; } - + File file = PropertiesUtil.findConfigFile(path); if (file == null) { file = new File(path); @@ -98,7 +98,7 @@ public class PropertiesStorage implements StorageComponent { return false; } } - + try { _properties.load(new FileInputStream(file)); _file = file; @@ -109,7 +109,7 @@ public class PropertiesStorage implements StorageComponent { s_logger.error("IOException: ", e); return false; } - + return true; } diff --git a/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java b/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java index ea68ae472dd..11c6eba11c0 100644 --- a/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java +++ b/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java @@ -66,7 +66,7 @@ public class DhcpPacketParser implements Runnable{ DHCPINFORM(8); int _type; DHCPMSGTYPE(int type) { - _type = type; + _type = type; } int getValue() { return _type; @@ -80,7 +80,7 @@ public class DhcpPacketParser implements Runnable{ return null; } } - + private class DHCPMSG { DHCPMSGTYPE msgType; byte[] caddr; @@ -93,13 +93,13 @@ public class DhcpPacketParser implements Runnable{ chaddr = new byte[6]; } } - + private PcapPacket _buffer; private int _offset; private int _len; private DhcpSnooperImpl _manager; - - + + public DhcpPacketParser(PcapPacket buffer, int offset, int len, DhcpSnooperImpl manager) { _buffer = buffer; _offset = offset; @@ -118,15 +118,15 @@ public class DhcpPacketParser implements Runnable{ private long getUInt(int offset) { return _buffer.getUInt(getPos(offset)); } - + private DHCPMSG getDhcpMsg() { long magic = getUInt(DHCPPACKET.MAGIC.getValue()); if (magic != 0x63538263) { return null; } - + DHCPMSG msg = new DHCPMSG(); - + int pos = DHCPPACKET.OPTIONS.getValue(); while (pos <= _len) { int type = (int)getByte(pos++) & 0xff; @@ -141,7 +141,7 @@ public class DhcpPacketParser implements Runnable{ if (pos <= _len) { len = ((int)getByte(pos++)) & 0xff; } - + if (type == DHCPOPTIONTYPE.MESSAGETYPE.getValue() || type == DHCPOPTIONTYPE.REQUESTEDIP.getValue()) { /*Read data only if needed */ byte[] data = null; @@ -149,17 +149,17 @@ public class DhcpPacketParser implements Runnable{ data = new byte[len]; getByteArray(pos, data); } - + if (type == DHCPOPTIONTYPE.MESSAGETYPE.getValue()) { msg.msgType = DHCPMSGTYPE.valueOf((int)data[0]); } else if (type == DHCPOPTIONTYPE.REQUESTEDIP.getValue()) { msg.requestedIP = data; } } - + pos += len; } - + if (msg.msgType == DHCPMSGTYPE.DHCPREQUEST) { getByteArray(DHCPPACKET.CHADDR.getValue(), msg.chaddr); getByteArray(DHCPPACKET.CIADDR.getValue(), msg.caddr); @@ -168,7 +168,7 @@ public class DhcpPacketParser implements Runnable{ } return msg; } - + private String formatMacAddress(byte[] mac) { StringBuffer sb = new StringBuffer(); Formatter formatter = new Formatter(sb); @@ -177,7 +177,7 @@ public class DhcpPacketParser implements Runnable{ } return sb.toString(); } - + private String getDestMacAddress() { Ethernet ether = new Ethernet(); if (_buffer.hasHeader(ether)) { @@ -186,7 +186,7 @@ public class DhcpPacketParser implements Runnable{ } return null; } - + private InetAddress getDHCPServerIP() { Ip4 ip = new Ip4(); if (_buffer.hasHeader(ip)) { @@ -198,7 +198,7 @@ public class DhcpPacketParser implements Runnable{ } return null; } - + @Override public void run() { DHCPMSG msg = getDhcpMsg(); @@ -206,7 +206,7 @@ public class DhcpPacketParser implements Runnable{ if (msg == null) { return; } - + if (msg.msgType == DHCPMSGTYPE.DHCPACK) { InetAddress ip = null; try { @@ -240,8 +240,8 @@ public class DhcpPacketParser implements Runnable{ } private void test() { - JPacket packet = new JMemoryPacket(Ethernet.ID, - " 06fa 8800 00b3 0656 d200 0027 8100 001a 0800 4500 0156 64bf 0000 4011 f3f2 ac1a 6412 ac1a 649e 0043 0044 0001 0000 0001"); + JPacket packet = new JMemoryPacket(Ethernet.ID, + " 06fa 8800 00b3 0656 d200 0027 8100 001a 0800 4500 0156 64bf 0000 4011 f3f2 ac1a 6412 ac1a 649e 0043 0044 0001 0000 0001"); Ethernet eth = new Ethernet(); if (packet.hasHeader(eth)) { System.out.print(" ether:" + eth); diff --git a/agent/src/com/cloud/agent/dhcp/DhcpProtocolParserServer.java b/agent/src/com/cloud/agent/dhcp/DhcpProtocolParserServer.java index 66fb7571ae5..9184d2023ac 100644 --- a/agent/src/com/cloud/agent/dhcp/DhcpProtocolParserServer.java +++ b/agent/src/com/cloud/agent/dhcp/DhcpProtocolParserServer.java @@ -24,7 +24,7 @@ public class DhcpProtocolParserServer extends Thread { _executor = new ThreadPoolExecutor(workers, 10 * workers, 1, TimeUnit.DAYS, new LinkedBlockingQueue(), new NamedThreadFactory("DhcpListener")); _running = true; } - + public void run() { while(_running) { try { diff --git a/agent/src/com/cloud/agent/dhcp/DhcpSnooper.java b/agent/src/com/cloud/agent/dhcp/DhcpSnooper.java index 03ed267163f..83f78f01bac 100644 --- a/agent/src/com/cloud/agent/dhcp/DhcpSnooper.java +++ b/agent/src/com/cloud/agent/dhcp/DhcpSnooper.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -10,10 +10,10 @@ * 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 . - * + * */ package com.cloud.agent.dhcp; @@ -27,7 +27,7 @@ import com.cloud.utils.component.Adapter; public interface DhcpSnooper extends Adapter{ public InetAddress getIPAddr(String macAddr, String vmName); - + public InetAddress getDhcpServerIP(); public void cleanup(String macAddr, String vmName); @@ -38,4 +38,4 @@ public interface DhcpSnooper extends Adapter{ public void initializeMacTable(List> macVmNameList); -} \ No newline at end of file +} diff --git a/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java b/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java index 2624294b8ef..9b49e70cb2d 100644 --- a/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java +++ b/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java @@ -15,9 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * + * * This software is licensed under the GNU General Public License v3 or later. - * + * * It 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 any later version. @@ -25,10 +25,10 @@ * 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 . - * + * */ package com.cloud.agent.dhcp; @@ -83,7 +83,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { private DhcpServer _server; protected long _timeout = 1200000; protected InetAddress _dhcpServerIp; - + public DhcpSnooperImpl(String bridge, long timeout) { _timeout = timeout; @@ -93,7 +93,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { _server = new DhcpServer(this, bridge); _server.start(); } - + @Override public InetAddress getIPAddr(String macAddr, String vmName) { @@ -105,7 +105,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { } else { addr._state = DHCPState.DHCPRESET; } - + synchronized(addr) { try { addr.wait(_timeout); @@ -116,14 +116,14 @@ public class DhcpSnooperImpl implements DhcpSnooper { return addr._ip; } } - + return null; } - + public InetAddress getDhcpServerIP() { return _dhcpServerIp; } - + @Override public void cleanup(String macAddr, String vmName) { @@ -137,7 +137,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { s_logger.debug("Failed to cleanup: " + e.toString()); } } - + @Override public Map syncIpAddr() { @@ -150,7 +150,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { } return vmIpMap; } - + @Override public void initializeMacTable(List> macVmNameList) { for (Pair macVmname : macVmNameList) { @@ -158,7 +158,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { _macIpMap.put(macVmname.first(), ipAdrr); } } - + protected void setIPAddr(String macAddr, InetAddress ip, DHCPState state, InetAddress dhcpServerIp) { String macAddrLowerCase = macAddr.toLowerCase(); if (state == DHCPState.DHCPREQUESTED) { @@ -166,7 +166,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { if (ipAddr == null) { return; } - + _ipMacMap.put(ip, macAddr); } else if (state == DHCPState.DHCPACKED) { _dhcpServerIp = dhcpServerIp; @@ -177,7 +177,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { return; } } - + IPAddr addr = _macIpMap.get(destMac); if (addr != null) { addr._ip = ip; @@ -188,7 +188,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { } } } - + /* (non-Javadoc) * @see com.cloud.agent.dhcp.DhcpSnooper#stop() */ @@ -198,7 +198,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { _server.StopServer(); return true; } - + private class DhcpServer extends Thread { private DhcpSnooperImpl _manager; private String _bridge; @@ -214,7 +214,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { _pcapedDev.breakloop(); _pcapedDev.close(); } - + private Pcap initializePcap() { try { List alldevs = new ArrayList(); @@ -265,7 +265,7 @@ public class DhcpSnooperImpl implements DhcpSnooper { } return null; } - + public void run() { while (_loop) { try { @@ -273,12 +273,12 @@ public class DhcpSnooperImpl implements DhcpSnooper { if (_pcapedDev == null) { return; } - + PcapPacketHandler jpacketHandler = new PcapPacketHandler() { public void nextPacket(PcapPacket packet, String user) { - Udp u = new Udp(); + Udp u = new Udp(); if (packet.hasHeader(u)) { - int offset = u.getOffset() + u.getLength(); + int offset = u.getOffset() + u.getLength(); _executor.execute(new DhcpPacketParser(packet, offset, u.length() - u.getLength(), _manager)); } } @@ -298,13 +298,13 @@ public class DhcpSnooperImpl implements DhcpSnooper { } } } - + static public void main(String args[]) { s_logger.addAppender(new org.apache.log4j.ConsoleAppender(new org.apache.log4j.PatternLayout(), "System.out")); final DhcpSnooperImpl manager = new DhcpSnooperImpl("cloudbr0", 10000); s_logger.debug(manager.getIPAddr("02:00:4c:66:00:03", "i-2-5-VM")); manager.stop(); - + } @Override diff --git a/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java b/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java index e6e2266ef12..b69c12f1975 100644 --- a/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java +++ b/agent/src/com/cloud/agent/dhcp/FakeDhcpSnooper.java @@ -111,7 +111,7 @@ public class FakeDhcpSnooper implements DhcpSnooper { @Override public void initializeMacTable(List> macVmNameList) { - + }