You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/12/12 22:01:20 UTC
[20/48] All Checkstyle problems corrected
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
index 6eaff88..31fd827 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
@@ -29,132 +29,132 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
-public class AsyncJobExecutionContext {
+public class AsyncJobExecutionContext {
private AsyncJob _job;
-
- static private AsyncJobManager _jobMgr;
- static private AsyncJobJoinMapDao _joinMapDao;
+
+ static private AsyncJobManager s_jobMgr;
+ static private AsyncJobJoinMapDao s_joinMapDao;
public static void init(AsyncJobManager jobMgr, AsyncJobJoinMapDao joinMapDao) {
- _jobMgr = jobMgr;
- _joinMapDao = joinMapDao;
+ s_jobMgr = jobMgr;
+ s_joinMapDao = joinMapDao;
+ }
+
+ private static ManagedThreadLocal<AsyncJobExecutionContext> s_currentExectionContext = new ManagedThreadLocal<AsyncJobExecutionContext>();
+
+ public AsyncJobExecutionContext() {
}
-
- private static ManagedThreadLocal<AsyncJobExecutionContext> s_currentExectionContext = new ManagedThreadLocal<AsyncJobExecutionContext>();
- public AsyncJobExecutionContext() {
- }
-
public AsyncJobExecutionContext(AsyncJob job) {
- _job = job;
- }
-
- public SyncQueueItem getSyncSource() {
- return _job.getSyncSource();
- }
-
- public void resetSyncSource() {
- _job.setSyncSource(null);
- }
-
+ _job = job;
+ }
+
+ public SyncQueueItem getSyncSource() {
+ return _job.getSyncSource();
+ }
+
+ public void resetSyncSource() {
+ _job.setSyncSource(null);
+ }
+
public AsyncJob getJob() {
- return _job;
- }
-
+ return _job;
+ }
+
public void setJob(AsyncJob job) {
- _job = job;
- }
-
+ _job = job;
+ }
+
public boolean isJobDispatchedBy(String jobDispatcherName) {
- assert(jobDispatcherName != null);
- if(_job != null && _job.getDispatcher() != null && _job.getDispatcher().equals(jobDispatcherName))
- return true;
-
- return false;
+ assert (jobDispatcherName != null);
+ if (_job != null && _job.getDispatcher() != null && _job.getDispatcher().equals(jobDispatcherName))
+ return true;
+
+ return false;
}
-
+
public void completeAsyncJob(JobInfo.Status jobStatus, int resultCode, String resultObject) {
assert (_job != null);
- _jobMgr.completeAsyncJob(_job.getId(), jobStatus, resultCode, resultObject);
+ s_jobMgr.completeAsyncJob(_job.getId(), jobStatus, resultCode, resultObject);
}
-
+
public void updateAsyncJobStatus(int processStatus, String resultObject) {
assert (_job != null);
- _jobMgr.updateAsyncJobStatus(_job.getId(), processStatus, resultObject);
+ s_jobMgr.updateAsyncJobStatus(_job.getId(), processStatus, resultObject);
}
-
+
public void updateAsyncJobAttachment(String instanceType, Long instanceId) {
assert (_job != null);
- _jobMgr.updateAsyncJobAttachment(_job.getId(), instanceType, instanceId);
+ s_jobMgr.updateAsyncJobAttachment(_job.getId(), instanceType, instanceId);
}
-
+
public void logJobJournal(AsyncJob.JournalType journalType, String journalText, String journalObjJson) {
assert (_job != null);
- _jobMgr.logJobJournal(_job.getId(), journalType, journalText, journalObjJson);
- }
+ s_jobMgr.logJobJournal(_job.getId(), journalType, journalText, journalObjJson);
+ }
public void log(Logger logger, String journalText) {
- _jobMgr.logJobJournal(_job.getId(), AsyncJob.JournalType.SUCCESS, journalText, null);
+ s_jobMgr.logJobJournal(_job.getId(), AsyncJob.JournalType.SUCCESS, journalText, null);
logger.debug(journalText);
}
public void joinJob(long joinJobId) {
assert (_job != null);
- _jobMgr.joinJob(_job.getId(), joinJobId);
+ s_jobMgr.joinJob(_job.getId(), joinJobId);
}
-
+
public void joinJob(long joinJobId, String wakeupHandler, String wakeupDispatcher, String[] wakeupTopcisOnMessageBus, long wakeupIntervalInMilliSeconds,
long timeoutInMilliSeconds) {
assert (_job != null);
- _jobMgr.joinJob(_job.getId(), joinJobId, wakeupHandler, wakeupDispatcher, wakeupTopcisOnMessageBus, wakeupIntervalInMilliSeconds, timeoutInMilliSeconds);
+ s_jobMgr.joinJob(_job.getId(), joinJobId, wakeupHandler, wakeupDispatcher, wakeupTopcisOnMessageBus, wakeupIntervalInMilliSeconds, timeoutInMilliSeconds);
}
-
+
+ //
+ // check failure exception before we disjoin the worker job
+ // TODO : it is ugly and this will become unnecessary after we switch to full-async mode
//
- // check failure exception before we disjoin the worker job
- // TODO : it is ugly and this will become unnecessary after we switch to full-async mode
- //
public void disjoinJob(long joinedJobId) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
assert (_job != null);
-
- AsyncJobJoinMapVO record = _joinMapDao.getJoinRecord(_job.getId(), joinedJobId);
+
+ AsyncJobJoinMapVO record = s_joinMapDao.getJoinRecord(_job.getId(), joinedJobId);
if (record.getJoinStatus() == JobInfo.Status.FAILED && record.getJoinResult() != null) {
- Object exception = JobSerializerHelper.fromObjectSerializedString(record.getJoinResult());
+ Object exception = JobSerializerHelper.fromObjectSerializedString(record.getJoinResult());
if (exception != null && exception instanceof Exception) {
if (exception instanceof InsufficientCapacityException)
- throw (InsufficientCapacityException)exception;
+ throw (InsufficientCapacityException)exception;
else if (exception instanceof ConcurrentOperationException)
- throw (ConcurrentOperationException)exception;
+ throw (ConcurrentOperationException)exception;
else if (exception instanceof ResourceUnavailableException)
- throw (ResourceUnavailableException)exception;
- else
- throw new RuntimeException((Exception)exception);
- }
- }
-
- _jobMgr.disjoinJob(_job.getId(), joinedJobId);
- }
-
+ throw (ResourceUnavailableException)exception;
+ else
+ throw new RuntimeException((Exception)exception);
+ }
+ }
+
+ s_jobMgr.disjoinJob(_job.getId(), joinedJobId);
+ }
+
public void completeJoin(JobInfo.Status joinStatus, String joinResult) {
assert (_job != null);
- _jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
+ s_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
}
-
+
public void completeJobAndJoin(JobInfo.Status joinStatus, String joinResult) {
assert (_job != null);
- _jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
- _jobMgr.completeAsyncJob(_job.getId(), joinStatus, 0, null);
+ s_jobMgr.completeJoin(_job.getId(), joinStatus, joinResult);
+ s_jobMgr.completeAsyncJob(_job.getId(), joinStatus, 0, null);
+ }
+
+ public static AsyncJobExecutionContext getCurrentExecutionContext() {
+ AsyncJobExecutionContext context = s_currentExectionContext.get();
+ return context;
}
- public static AsyncJobExecutionContext getCurrentExecutionContext() {
- AsyncJobExecutionContext context = s_currentExectionContext.get();
- return context;
- }
-
public static AsyncJobExecutionContext registerPseudoExecutionContext(long accountId, long userId) {
AsyncJobExecutionContext context = s_currentExectionContext.get();
if (context == null) {
context = new AsyncJobExecutionContext();
- context.setJob(_jobMgr.getPseudoJob(accountId, userId));
+ context.setJob(s_jobMgr.getPseudoJob(accountId, userId));
setCurrentExecutionContext(context);
}
@@ -166,9 +166,9 @@ public class AsyncJobExecutionContext {
setCurrentExecutionContext(null);
return context;
}
-
+
// This is intended to be package level access for AsyncJobManagerImpl only.
public static void setCurrentExecutionContext(AsyncJobExecutionContext currentContext) {
- s_currentExectionContext.set(currentContext);
- }
+ s_currentExectionContext.set(currentContext);
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java
----------------------------------------------------------------------
diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java
index 57377bc..2db3aaf 100644
--- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java
+++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java
@@ -35,7 +35,7 @@ public class ManagedThreadLocal<T> extends ThreadLocal<T> {
}
};
- private static boolean VALIDATE_CONTEXT = false;
+ private static boolean s_validateContext = false;
private static final Logger log = LoggerFactory.getLogger(ManagedThreadLocal.class);
@SuppressWarnings("unchecked")
@@ -70,13 +70,13 @@ public class ManagedThreadLocal<T> extends ThreadLocal<T> {
}
private static void validateInContext(Object tl) {
- if (VALIDATE_CONTEXT && !ManagedContextUtils.isInContext()) {
+ if (s_validateContext && !ManagedContextUtils.isInContext()) {
String msg = "Using a managed thread local in a non managed context this WILL cause errors at runtime. TL [" + tl + "]";
log.error(msg, new IllegalStateException(msg));
}
}
public static void setValidateInContext(boolean validate) {
- VALIDATE_CONTEXT = validate;
+ s_validateContext = validate;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
----------------------------------------------------------------------
diff --git a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
index de14007..1316a92 100644
--- a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
+++ b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
@@ -125,8 +125,8 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC
}
@Inject
- public void setServices(List<PluggableService> _services) {
- this._services = _services;
+ public void setServices(List<PluggableService> services) {
+ this._services = services;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
index 39d965d..cb691a9 100755
--- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
@@ -262,8 +262,8 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A
return _apiAccessCheckers;
}
- public void setApiAccessCheckers(List<APIChecker> _apiAccessCheckers) {
- this._apiAccessCheckers = _apiAccessCheckers;
+ public void setApiAccessCheckers(List<APIChecker> apiAccessCheckers) {
+ this._apiAccessCheckers = apiAccessCheckers;
}
public List<PluggableService> getServices() {
@@ -271,7 +271,7 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A
}
@Inject
- public void setServices(List<PluggableService> _services) {
- this._services = _services;
+ public void setServices(List<PluggableService> services) {
+ this._services = services;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java b/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
index f861ae9..30cb0bc 100644
--- a/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
+++ b/plugins/api/discovery/test/org/apache/cloudstack/discovery/ApiDiscoveryTest.java
@@ -46,9 +46,9 @@ import com.cloud.user.UserVO;
import com.cloud.utils.component.PluggableService;
public class ApiDiscoveryTest {
- private static APIChecker _apiChecker = mock(APIChecker.class);
- private static PluggableService _pluggableService = mock(PluggableService.class);
- private static ApiDiscoveryServiceImpl _discoveryService = new ApiDiscoveryServiceImpl();
+ private static APIChecker s_apiChecker = mock(APIChecker.class);
+ private static PluggableService s_pluggableService = mock(PluggableService.class);
+ private static ApiDiscoveryServiceImpl s_discoveryService = new ApiDiscoveryServiceImpl();
private static Class<?> testCmdClass = ListApisCmd.class;
private static User testUser;
@@ -65,23 +65,23 @@ public class ApiDiscoveryTest {
testApiAsync = false;
testUser = new UserVO();
- _discoveryService._apiAccessCheckers = mock(List.class);
- _discoveryService._services = mock(List.class);
+ s_discoveryService._apiAccessCheckers = mock(List.class);
+ s_discoveryService._services = mock(List.class);
- when(_apiChecker.checkAccess(any(User.class), anyString())).thenReturn(true);
- when(_pluggableService.getCommands()).thenReturn(new ArrayList<Class<?>>());
- when(_discoveryService._apiAccessCheckers.iterator()).thenReturn(Arrays.asList(_apiChecker).iterator());
- when(_discoveryService._services.iterator()).thenReturn(Arrays.asList(_pluggableService).iterator());
+ when(s_apiChecker.checkAccess(any(User.class), anyString())).thenReturn(true);
+ when(s_pluggableService.getCommands()).thenReturn(new ArrayList<Class<?>>());
+ when(s_discoveryService._apiAccessCheckers.iterator()).thenReturn(Arrays.asList(s_apiChecker).iterator());
+ when(s_discoveryService._services.iterator()).thenReturn(Arrays.asList(s_pluggableService).iterator());
Set<Class<?>> cmdClasses = new HashSet<Class<?>>();
cmdClasses.add(ListApisCmd.class);
- _discoveryService.start();
- _discoveryService.cacheResponseMap(cmdClasses);
+ s_discoveryService.start();
+ s_discoveryService.cacheResponseMap(cmdClasses);
}
@Test
public void verifyListSingleApi() throws Exception {
- ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)_discoveryService.listApis(testUser, testApiName);
+ ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser, testApiName);
ApiDiscoveryResponse response = responses.getResponses().get(0);
assertTrue("No. of response items should be one", responses.getCount() == 1);
assertEquals("Error in api name", testApiName, response.getName());
@@ -92,7 +92,7 @@ public class ApiDiscoveryTest {
@Test
public void verifyListApis() throws Exception {
- ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)_discoveryService.listApis(testUser, null);
+ ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser, null);
assertTrue("No. of response items > 1", responses.getCount() == 1);
for (ApiDiscoveryResponse response : responses.getResponses()) {
assertFalse("API name is empty", response.getName().isEmpty());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java
----------------------------------------------------------------------
diff --git a/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java b/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java
index c907042..0091b15 100644
--- a/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java
+++ b/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java
@@ -46,50 +46,50 @@ import com.cloud.user.UserVO;
public class ApiRateLimitTest {
- static ApiRateLimitServiceImpl _limitService = new ApiRateLimitServiceImpl();
- static AccountService _accountService = mock(AccountService.class);
- static ConfigurationDao _configDao = mock(ConfigurationDao.class);
- private static long acctIdSeq = 5L;
- private static Account testAccount;
+ static ApiRateLimitServiceImpl s_limitService = new ApiRateLimitServiceImpl();
+ static AccountService s_accountService = mock(AccountService.class);
+ static ConfigurationDao s_configDao = mock(ConfigurationDao.class);
+ private static long s_acctIdSeq = 5L;
+ private static Account s_testAccount;
@BeforeClass
public static void setUp() throws ConfigurationException {
- when(_configDao.getValue(Config.ApiLimitInterval.key())).thenReturn(null);
- when(_configDao.getValue(Config.ApiLimitMax.key())).thenReturn(null);
- when(_configDao.getValue(Config.ApiLimitCacheSize.key())).thenReturn(null);
- when(_configDao.getValue(Config.ApiLimitEnabled.key())).thenReturn("true"); // enable api rate limiting
- _limitService._configDao = _configDao;
+ when(s_configDao.getValue(Config.ApiLimitInterval.key())).thenReturn(null);
+ when(s_configDao.getValue(Config.ApiLimitMax.key())).thenReturn(null);
+ when(s_configDao.getValue(Config.ApiLimitCacheSize.key())).thenReturn(null);
+ when(s_configDao.getValue(Config.ApiLimitEnabled.key())).thenReturn("true"); // enable api rate limiting
+ s_limitService._configDao = s_configDao;
- _limitService.configure("ApiRateLimitTest", Collections.<String, Object> emptyMap());
+ s_limitService.configure("ApiRateLimitTest", Collections.<String, Object> emptyMap());
- _limitService._accountService = _accountService;
+ s_limitService._accountService = s_accountService;
// Standard responses
- AccountVO acct = new AccountVO(acctIdSeq);
+ AccountVO acct = new AccountVO(s_acctIdSeq);
acct.setType(Account.ACCOUNT_TYPE_NORMAL);
acct.setAccountName("demo");
- testAccount = acct;
+ s_testAccount = acct;
- when(_accountService.getAccount(5L)).thenReturn(testAccount);
- when(_accountService.isRootAdmin(Account.ACCOUNT_TYPE_NORMAL)).thenReturn(false);
+ when(s_accountService.getAccount(5L)).thenReturn(s_testAccount);
+ when(s_accountService.isRootAdmin(Account.ACCOUNT_TYPE_NORMAL)).thenReturn(false);
}
@Before
public void testSetUp() {
// reset counter for each test
- _limitService.resetApiLimit(null);
+ s_limitService.resetApiLimit(null);
}
private User createFakeUser() {
UserVO user = new UserVO();
- user.setAccountId(acctIdSeq);
+ user.setAccountId(s_acctIdSeq);
return user;
}
private boolean isUnderLimit(User key) {
try {
- _limitService.checkAccess(key, null);
+ s_limitService.checkAccess(key, null);
return true;
} catch (RequestLimitException ex) {
return false;
@@ -99,8 +99,8 @@ public class ApiRateLimitTest {
@Test
public void sequentialApiAccess() {
int allowedRequests = 1;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
User key = createFakeUser();
assertTrue("Allow for the first request", isUnderLimit(key));
@@ -111,8 +111,8 @@ public class ApiRateLimitTest {
@Test
public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
int allowedRequests = 200;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
User key = createFakeUser();
@@ -126,8 +126,8 @@ public class ApiRateLimitTest {
@Test
public void multipleClientsCanAccessWithoutBlocking() throws Exception {
int allowedRequests = 200;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
final User key = createFakeUser();
@@ -180,8 +180,8 @@ public class ApiRateLimitTest {
@Test
public void expiryOfCounterIsSupported() throws Exception {
int allowedRequests = 1;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
User key = this.createFakeUser();
@@ -196,8 +196,8 @@ public class ApiRateLimitTest {
@Test
public void verifyResetCounters() throws Exception {
int allowedRequests = 1;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
User key = this.createFakeUser();
@@ -205,7 +205,7 @@ public class ApiRateLimitTest {
assertFalse("Another request should be blocked", isUnderLimit(key));
- _limitService.resetApiLimit(key.getAccountId());
+ s_limitService.resetApiLimit(key.getAccountId());
assertTrue("Another request should be allowed after reset counter", isUnderLimit(key));
}
@@ -213,8 +213,8 @@ public class ApiRateLimitTest {
@Test
public void verifySearchCounter() throws Exception {
int allowedRequests = 10;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
User key = this.createFakeUser();
@@ -222,7 +222,7 @@ public class ApiRateLimitTest {
assertTrue("Issued 5 requests", isUnderLimit(key));
}
- ApiLimitResponse response = _limitService.searchApiLimit(testAccount);
+ ApiLimitResponse response = s_limitService.searchApiLimit(s_testAccount);
assertEquals("apiIssued is incorrect", 5, response.getApiIssued());
assertEquals("apiAllowed is incorrect", 5, response.getApiAllowed());
// using <= to account for inaccurate System.currentTimeMillis() clock in Windows environment
@@ -234,9 +234,9 @@ public class ApiRateLimitTest {
public void disableApiLimit() throws Exception {
try {
int allowedRequests = 200;
- _limitService.setMaxAllowed(allowedRequests);
- _limitService.setTimeToLive(1);
- _limitService.setEnabled(false);
+ s_limitService.setMaxAllowed(allowedRequests);
+ s_limitService.setTimeToLive(1);
+ s_limitService.setEnabled(false);
User key = createFakeUser();
@@ -244,7 +244,7 @@ public class ApiRateLimitTest {
assertTrue("We should allow more than " + allowedRequests + " requests per second when api throttling is disabled.", isUnderLimit(key));
}
} finally {
- _limitService.setEnabled(true); // enable api throttling to avoid
+ s_limitService.setEnabled(true); // enable api throttling to avoid
// impacting other testcases
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
index 110fd7b..4182193 100644
--- a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
+++ b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
@@ -59,7 +59,6 @@ import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityManager;
-import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.DataCenterVO;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
----------------------------------------------------------------------
diff --git a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
index c1a4ee2..8ad7033 100644
--- a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
+++ b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
@@ -70,13 +70,13 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
private static Integer retryInterval;
// hashmap to book keep the registered subscribers
- private static ConcurrentHashMap<String, Ternary<String, Channel, EventSubscriber>> _subscribers;
+ private static ConcurrentHashMap<String, Ternary<String, Channel, EventSubscriber>> s_subscribers;
// connection to AMQP server,
- private static Connection _connection = null;
+ private static Connection s_connection = null;
// AMQP server should consider messages acknowledged once delivered if _autoAck is true
- private static boolean _autoAck = true;
+ private static boolean s_autoAck = true;
private ExecutorService executorService;
private static DisconnectHandler disconnectHandler;
@@ -114,7 +114,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
throw new ConfigurationException("Invalid port number/retry interval");
}
- _subscribers = new ConcurrentHashMap<String, Ternary<String, Channel, EventSubscriber>>();
+ s_subscribers = new ConcurrentHashMap<String, Ternary<String, Channel, EventSubscriber>>();
executorService = Executors.newCachedThreadPool();
disconnectHandler = new DisconnectHandler();
@@ -173,7 +173,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
String bindingKey = createBindingKey(topic);
// store the subscriber details before creating channel
- _subscribers.put(queueName, new Ternary(bindingKey, null, subscriber));
+ s_subscribers.put(queueName, new Ternary(bindingKey, null, subscriber));
// create a channel dedicated for this subscription
Connection connection = getConnection();
@@ -185,10 +185,10 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
channel.queueBind(queueName, amqpExchangeName, bindingKey);
// register a callback handler to receive the events that a subscriber subscribed to
- channel.basicConsume(queueName, _autoAck, queueName, new DefaultConsumer(channel) {
+ channel.basicConsume(queueName, s_autoAck, queueName, new DefaultConsumer(channel) {
@Override
public void handleDelivery(String queueName, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
- Ternary<String, Channel, EventSubscriber> queueDetails = _subscribers.get(queueName);
+ Ternary<String, Channel, EventSubscriber> queueDetails = s_subscribers.get(queueName);
if (queueDetails != null) {
EventSubscriber subscriber = queueDetails.third();
String routingKey = envelope.getRoutingKey();
@@ -207,9 +207,9 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
});
// update the channel details for the subscription
- Ternary<String, Channel, EventSubscriber> queueDetails = _subscribers.get(queueName);
+ Ternary<String, Channel, EventSubscriber> queueDetails = s_subscribers.get(queueName);
queueDetails.second(channel);
- _subscribers.put(queueName, queueDetails);
+ s_subscribers.put(queueName, queueDetails);
} catch (AlreadyClosedException closedException) {
s_logger.warn("Connection to AMQP service is lost. Subscription:" + queueName + " will be active after reconnection");
@@ -227,10 +227,10 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
try {
String classname = subscriber.getClass().getName();
String queueName = UUID.nameUUIDFromBytes(classname.getBytes()).toString();
- Ternary<String, Channel, EventSubscriber> queueDetails = _subscribers.get(queueName);
+ Ternary<String, Channel, EventSubscriber> queueDetails = s_subscribers.get(queueName);
Channel channel = queueDetails.second();
channel.basicCancel(queueName);
- _subscribers.remove(queueName, queueDetails);
+ s_subscribers.remove(queueName, queueDetails);
} catch (Exception e) {
throw new EventBusException("Failed to unsubscribe from event bus due to " + e.getMessage());
}
@@ -330,7 +330,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
}
private synchronized Connection getConnection() throws Exception {
- if (_connection == null) {
+ if (s_connection == null) {
try {
return createConnection();
} catch (Exception e) {
@@ -338,7 +338,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
throw e;
}
} else {
- return _connection;
+ return s_connection;
}
}
@@ -352,8 +352,8 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
factory.setPort(port);
Connection connection = factory.newConnection();
connection.addShutdownListener(disconnectHandler);
- _connection = connection;
- return _connection;
+ s_connection = connection;
+ return s_connection;
} catch (Exception e) {
throw e;
}
@@ -361,25 +361,25 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
private synchronized void closeConnection() {
try {
- if (_connection != null) {
- _connection.close();
+ if (s_connection != null) {
+ s_connection.close();
}
} catch (Exception e) {
s_logger.warn("Failed to close connection to AMQP server due to " + e.getMessage());
}
- _connection = null;
+ s_connection = null;
}
private synchronized void abortConnection() {
- if (_connection == null)
+ if (s_connection == null)
return;
try {
- _connection.abort();
+ s_connection.abort();
} catch (Exception e) {
s_logger.warn("Failed to abort connection due to " + e.getMessage());
}
- _connection = null;
+ s_connection = null;
}
private String replaceNullWithWildcard(String key) {
@@ -458,9 +458,9 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
@Override
public boolean stop() {
- if (_connection.isOpen()) {
- for (String subscriberId : _subscribers.keySet()) {
- Ternary<String, Channel, EventSubscriber> subscriberDetails = _subscribers.get(subscriberId);
+ if (s_connection.isOpen()) {
+ for (String subscriberId : s_subscribers.keySet()) {
+ Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
Channel channel = subscriberDetails.second();
String queueName = subscriberId;
try {
@@ -483,10 +483,10 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
public void shutdownCompleted(ShutdownSignalException shutdownSignalException) {
if (!shutdownSignalException.isInitiatedByApplication()) {
- for (String subscriberId : _subscribers.keySet()) {
- Ternary<String, Channel, EventSubscriber> subscriberDetails = _subscribers.get(subscriberId);
+ for (String subscriberId : s_subscribers.keySet()) {
+ Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
subscriberDetails.second(null);
- _subscribers.put(subscriberId, subscriberDetails);
+ s_subscribers.put(subscriberId, subscriberDetails);
}
abortConnection(); // disconnected to AMQP server, so abort the connection and channels
@@ -524,8 +524,8 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
}
// prepare consumer on AMQP server for each of subscriber
- for (String subscriberId : _subscribers.keySet()) {
- Ternary<String, Channel, EventSubscriber> subscriberDetails = _subscribers.get(subscriberId);
+ for (String subscriberId : s_subscribers.keySet()) {
+ Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
String bindingKey = subscriberDetails.first();
EventSubscriber subscriber = subscriberDetails.third();
@@ -538,11 +538,11 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
channel.queueBind(subscriberId, amqpExchangeName, bindingKey);
// register a callback handler to receive the events that a subscriber subscribed to
- channel.basicConsume(subscriberId, _autoAck, subscriberId, new DefaultConsumer(channel) {
+ channel.basicConsume(subscriberId, s_autoAck, subscriberId, new DefaultConsumer(channel) {
@Override
public void handleDelivery(String queueName, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
- Ternary<String, Channel, EventSubscriber> subscriberDetails = _subscribers.get(queueName); // queue name == subscriber ID
+ Ternary<String, Channel, EventSubscriber> subscriberDetails = s_subscribers.get(queueName); // queue name == subscriber ID
if (subscriberDetails != null) {
EventSubscriber subscriber = subscriberDetails.third();
@@ -565,7 +565,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
// update the channel details for the subscription
subscriberDetails.second(channel);
- _subscribers.put(subscriberId, subscriberDetails);
+ s_subscribers.put(subscriberId, subscriberDetails);
}
} catch (Exception e) {
s_logger.warn("Failed to recreate queues and binding for the subscribers due to " + e.getMessage());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/file-systems/netapp/src/com/cloud/netapp/NetappDefaultAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappDefaultAllocatorImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappDefaultAllocatorImpl.java
index f42be33..0141825 100644
--- a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappDefaultAllocatorImpl.java
+++ b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappDefaultAllocatorImpl.java
@@ -16,18 +16,15 @@
// under the License.
package com.cloud.netapp;
-import java.io.IOException;
import java.rmi.ServerException;
import java.util.HashMap;
import java.util.List;
-import netapp.manage.NaException;
-
import org.apache.log4j.Logger;
public class NetappDefaultAllocatorImpl implements NetappAllocator {
- private static HashMap<String, Integer> _poolNameToLastVolumeIdAllocated = new HashMap<String, Integer>();
- private NetappManager _netappMgr;
+ private static HashMap<String, Integer> s_poolNameToLastVolumeIdAllocated = new HashMap<String, Integer>();
+ private final NetappManager _netappMgr;
public static final Logger s_logger = Logger.getLogger(NetappDefaultAllocatorImpl.class.getName());
public NetappDefaultAllocatorImpl(NetappManager netappMgr) {
@@ -67,8 +64,6 @@ public class NetappDefaultAllocatorImpl implements NetappAllocator {
* @param poolName
* @param lunSizeGb
* @return -- the selected volume to create the lun on
- * @throws IOException
- * @throws NaException
*/
@Override
public synchronized NetappVolumeVO chooseVolumeFromPool(String poolName, long lunSizeGb) {
@@ -81,14 +76,14 @@ public class NetappDefaultAllocatorImpl implements NetappAllocator {
}
//get the index of the record from the map
- if (_poolNameToLastVolumeIdAllocated.get(poolName) == null) {
+ if (s_poolNameToLastVolumeIdAllocated.get(poolName) == null) {
pos = 0;
} else {
- pos = _poolNameToLastVolumeIdAllocated.get(poolName);
+ pos = s_poolNameToLastVolumeIdAllocated.get(poolName);
}
//update for RR effect
- _poolNameToLastVolumeIdAllocated.put(poolName, (pos + 1) % volumesOnPoolAscending.size());
+ s_poolNameToLastVolumeIdAllocated.put(poolName, (pos + 1) % volumesOnPoolAscending.size());
//now iterate over the records
Object[] volumesOnPoolAscendingArray = volumesOnPoolAscending.toArray();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
index 10a619c..510e6c6 100644
--- a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
+++ b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java
@@ -31,10 +31,8 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import netapp.manage.NaAPIFailedException;
-import netapp.manage.NaAuthenticationException;
import netapp.manage.NaElement;
import netapp.manage.NaException;
-import netapp.manage.NaProtocolException;
import netapp.manage.NaServer;
import org.apache.log4j.Logger;
@@ -208,10 +206,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager {
* @param volName -- name of volume to destroy
* @throws ResourceInUseException
* @throws NaException
- * @throws IOException
- * @throws NaProtocolException
* @throws NaAPIFailedException
- * @throws NaAuthenticationException
*/
@Override
@DB
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
index 8a87285..66bbb61 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
@@ -41,7 +41,7 @@ import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev;
import com.cloud.agent.api.baremetal.PreparePxeServerAnswer;
import com.cloud.agent.api.baremetal.PreparePxeServerCommand;
-import com.cloud.agent.api.baremetal.prepareCreateTemplateCommand;
+import com.cloud.agent.api.baremetal.PrepareCreateTemplateCommand;
import com.cloud.baremetal.database.BaremetalPxeDao;
import com.cloud.baremetal.database.BaremetalPxeVO;
import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType;
@@ -148,7 +148,7 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
}
try {
- prepareCreateTemplateCommand cmd = new prepareCreateTemplateCommand(ip, mac, mask, gateway, dns, templateUrl);
+ PrepareCreateTemplateCommand cmd = new PrepareCreateTemplateCommand(ip, mac, mask, gateway, dns, templateUrl);
Answer ans = _agentMgr.send(pxeServerId, cmd);
return ans.getResult();
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
index 6fc6a28..b677a63 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
@@ -42,7 +42,7 @@ import com.cloud.vm.VirtualMachine.State;
public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase {
private static final Logger s_logger = Logger.getLogger(BaremetalKickStartPxeResource.class);
- private static final String _name = "BaremetalKickStartPxeResource";
+ private static final String Name = "BaremetalKickStartPxeResource";
String _tftpDir;
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPingPxeResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPingPxeResource.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPingPxeResource.java
index ddad9b6..a7fd77e 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPingPxeResource.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPingPxeResource.java
@@ -39,7 +39,7 @@ import com.cloud.agent.api.PingCommand;
import com.cloud.agent.api.PingRoutingCommand;
import com.cloud.agent.api.baremetal.PreparePxeServerAnswer;
import com.cloud.agent.api.baremetal.PreparePxeServerCommand;
-import com.cloud.agent.api.baremetal.prepareCreateTemplateCommand;
+import com.cloud.agent.api.baremetal.PrepareCreateTemplateCommand;
import com.cloud.agent.api.routing.VmDataCommand;
import com.cloud.utils.script.Script;
import com.cloud.utils.ssh.SSHCmdHelper;
@@ -47,7 +47,7 @@ import com.cloud.vm.VirtualMachine.State;
public class BaremetalPingPxeResource extends BaremetalPxeResourceBase {
private static final Logger s_logger = Logger.getLogger(BaremetalPingPxeResource.class);
- private static final String _name = "BaremetalPingPxeResource";
+ private static final String Name = "BaremetalPingPxeResource";
String _storageServer;
String _pingDir;
String _share;
@@ -175,7 +175,7 @@ public class BaremetalPingPxeResource extends BaremetalPxeResourceBase {
}
}
- protected Answer execute(prepareCreateTemplateCommand cmd) {
+ protected Answer execute(PrepareCreateTemplateCommand cmd) {
com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);
try {
sshConnection.connect(null, 60000, 60000);
@@ -207,8 +207,8 @@ public class BaremetalPingPxeResource extends BaremetalPxeResourceBase {
public Answer executeRequest(Command cmd) {
if (cmd instanceof PreparePxeServerCommand) {
return execute((PreparePxeServerCommand)cmd);
- } else if (cmd instanceof prepareCreateTemplateCommand) {
- return execute((prepareCreateTemplateCommand)cmd);
+ } else if (cmd instanceof PrepareCreateTemplateCommand) {
+ return execute((PrepareCreateTemplateCommand)cmd);
} else if (cmd instanceof VmDataCommand) {
return execute((VmDataCommand)cmd);
} else {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
index b60a67b..4689fbc 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
@@ -85,7 +85,7 @@ public class BaremetalUserdataElement extends AdapterBase implements NetworkElem
}
@Override
- public boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile vm, String SSHPublicKey) throws ResourceUnavailableException {
+ public boolean saveSSHKey(Network network, NicProfile nic, VirtualMachineProfile vm, String sshPublicKey) throws ResourceUnavailableException {
// TODO Auto-generated method stub
return false;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
index 2b81fa6..371a618 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
@@ -16,12 +16,8 @@
// under the License.
package com.cloud.hypervisor.hyperv.discoverer;
-import java.io.File;
-import java.io.IOException;
import java.net.InetAddress;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
@@ -35,10 +31,6 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
-import org.apache.cloudstack.utils.identity.ManagementServerNode;
-
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
@@ -51,7 +43,6 @@ import com.cloud.agent.api.SetupCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.alert.AlertManager;
-import com.cloud.configuration.Config;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterVO;
@@ -77,13 +68,7 @@ import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
-import com.cloud.storage.JavaStorageLayer;
import com.cloud.storage.StorageLayer;
-import com.cloud.utils.FileUtil;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
/**
* Methods to discover and managem a Hyper-V agent. Prepares a
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java
index f21683d..27745c0 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java
@@ -30,11 +30,12 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import org.apache.log4j.Logger;
+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.log4j.Logger;
import com.cloud.configuration.Config;
import com.cloud.storage.JavaStorageLayer;
@@ -45,7 +46,7 @@ import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
-@Local(value = { HypervManager.class })
+@Local(value = {HypervManager.class})
public class HypervManagerImpl implements HypervManager {
public static final Logger s_logger = Logger.getLogger(HypervManagerImpl.class);
@@ -59,8 +60,10 @@ public class HypervManagerImpl implements HypervManager {
Map<String, String> _storageMounts = new HashMap<String, String>();
StorageLayer _storage;
- @Inject ConfigurationDao _configDao;
- @Inject DataStoreManager _dataStoreMgr;
+ @Inject
+ ConfigurationDao _configDao;
+ @Inject
+ DataStoreManager _dataStoreMgr;
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -150,11 +153,11 @@ public class HypervManagerImpl implements HypervManager {
GlobalLock lock = GlobalLock.getInternLock("prepare.systemvm");
try {
- if(lock.lock(3600)) {
+ if (lock.lock(3600)) {
try {
File patchFolder = new File(mountPoint + "/systemvm");
- if(!patchFolder.exists()) {
- if(!patchFolder.mkdirs()) {
+ if (!patchFolder.exists()) {
+ if (!patchFolder.mkdirs()) {
String msg = "Unable to create systemvm folder on secondary storage. location: " + patchFolder.toString();
s_logger.error(msg);
throw new CloudRuntimeException(msg);
@@ -163,12 +166,12 @@ public class HypervManagerImpl implements HypervManager {
File srcIso = getSystemVMPatchIsoFile();
File destIso = new File(mountPoint + "/systemvm/" + getSystemVMIsoFileNameOnDatastore());
- if(!destIso.exists()) {
+ if (!destIso.exists()) {
s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: " +
- srcIso.getAbsolutePath() + ", destination: " + destIso.getAbsolutePath());
+ srcIso.getAbsolutePath() + ", destination: " + destIso.getAbsolutePath());
try {
FileUtil.copyfile(srcIso, destIso);
- } catch(IOException e) {
+ } catch (IOException e) {
s_logger.error("Unexpected exception ", e);
String msg = "Unable to copy systemvm ISO on secondary storage. src location: " + srcIso.toString() + ", dest location: " + destIso;
@@ -176,7 +179,7 @@ public class HypervManagerImpl implements HypervManager {
throw new CloudRuntimeException(msg);
}
} else {
- if(s_logger.isTraceEnabled()) {
+ if (s_logger.isTraceEnabled()) {
s_logger.trace("SystemVM ISO file " + destIso.getPath() + " already exists");
}
}
@@ -191,9 +194,9 @@ public class HypervManagerImpl implements HypervManager {
private String getMountPoint(String storageUrl) {
String mountPoint = null;
- synchronized(_storageMounts) {
+ synchronized (_storageMounts) {
mountPoint = _storageMounts.get(storageUrl);
- if(mountPoint != null) {
+ if (mountPoint != null) {
return mountPoint;
}
@@ -206,8 +209,8 @@ public class HypervManagerImpl implements HypervManager {
}
mountPoint = mount(File.separator + File.separator + uri.getHost() + uri.getPath(), getMountParent(),
- uri.getScheme(), uri.getQuery());
- if(mountPoint == null) {
+ uri.getScheme(), uri.getQuery());
+ if (mountPoint == null) {
s_logger.error("Unable to create mount point for " + storageUrl);
return "/mnt/sec";
}
@@ -290,12 +293,12 @@ public class HypervManagerImpl implements HypervManager {
isoFile = new File(url.getPath());
}
- if(isoFile == null || !isoFile.exists()) {
+ if (isoFile == null || !isoFile.exists()) {
isoFile = new File("/usr/share/cloudstack-common/vms/systemvm.iso");
}
- assert(isoFile != null);
- if(!isoFile.exists()) {
+ assert (isoFile != null);
+ if (!isoFile.exists()) {
s_logger.error("Unable to locate systemvm.iso in your setup at " + isoFile.toString());
}
return isoFile;
@@ -326,8 +329,8 @@ public class HypervManagerImpl implements HypervManager {
// cleanup left-over NFS mounts from previous session
String[] mounts = _storage.listFiles(parent + File.separator + String.valueOf(mshostId) + ".*");
- if(mounts != null && mounts.length > 0) {
- for(String mountPoint : mounts) {
+ if (mounts != null && mounts.length > 0) {
+ for (String mountPoint : mounts) {
s_logger.info("umount NFS mount from previous session: " + mountPoint);
String result = null;
@@ -348,7 +351,7 @@ public class HypervManagerImpl implements HypervManager {
private void shutdownCleanup() {
s_logger.info("Cleanup mounted mount points used in current session");
- for(String mountPoint : _storageMounts.values()) {
+ for (String mountPoint : _storageMounts.values()) {
s_logger.info("umount NFS mount: " + mountPoint);
String result = null;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
index 6c4babd..5de3d70 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -112,7 +112,6 @@ import com.cloud.utils.net.NetUtils;
import com.cloud.utils.ssh.SshHelper;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineName;
-import com.google.gson.Gson;
/**
* Implementation of dummy resource to be returned from discoverer.
@@ -128,12 +127,12 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
private String _clusterId;
private String _guid;
private String _agentIp;
- private int _port = DEFAULT_AGENT_PORT;
- protected final long _ops_timeout = 900000; // 15 minutes time out to time
+ private final int _port = DEFAULT_AGENT_PORT;
+ protected final long _opsTimeout = 900000; // 15 minutes time out to time
protected final int _retry = 24;
protected final int _sleep = 10000;
- protected final int DEFAULT_DOMR_SSHPORT = 3922;
+ protected static final int DEFAULT_DOMR_SSHPORT = 3922;
private String _clusterGuid;
@@ -145,14 +144,14 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
private String _password;
private static HypervManager s_hypervMgr;
- @Inject HypervManager _hypervMgr;
+ @Inject
+ HypervManager _hypervMgr;
@PostConstruct
void init() {
s_hypervMgr = _hypervMgr;
}
-
@Override
public final Type getType() {
return Type.Routing;
@@ -383,7 +382,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
} else if (clazz == CheckS2SVpnConnectionsCommand.class) {
answer = execute((CheckS2SVpnConnectionsCommand)cmd);
} else if (clazz == SetStaticRouteCommand.class) {
- answer = execute((SetStaticRouteCommand) cmd);
+ answer = execute((SetStaticRouteCommand)cmd);
} else {
if (clazz == StartCommand.class) {
VirtualMachineTO vmSpec = ((StartCommand)cmd).getVirtualMachine();
@@ -633,7 +632,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
if (s_logger.isDebugEnabled())
s_logger.debug("Run domr script " + cmd);
Pair<Boolean, String> result2 = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
- // TODO need to find the dev index inside router based on IP address
+ // TODO need to find the dev index inside router based on IP address
cmd);
if (s_logger.isDebugEnabled())
s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
@@ -960,14 +959,16 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
String args = " -v " + vmIpAddress;
if (s_logger.isDebugEnabled()) {
- s_logger.debug("Run command on domain router " + controlIp + ", /opt/cloud/bin/savepassword.sh " + args + " -p " + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
+ s_logger.debug("Run command on domain router " + controlIp + ", /opt/cloud/bin/savepassword.sh " + args + " -p " +
+ StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
}
args += " -p " + password;
try {
- Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/savepassword.sh " + args);
+ Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/savepassword.sh " +
+ args);
if (!result.first()) {
s_logger.error("savepassword command on domain router " + controlIp + " failed, message: " + result.second());
@@ -1608,17 +1609,17 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
/* todo: update, make consistent with the xen server equivalent. */
if (params != null) {
- _guid = (String) params.get("guid");
- _zoneId = (String) params.get("zone");
- _podId = (String) params.get("pod");
- _clusterId = (String) params.get("cluster");
- _agentIp = (String) params.get("ipaddress"); // was agentIp
+ _guid = (String)params.get("guid");
+ _zoneId = (String)params.get("zone");
+ _podId = (String)params.get("pod");
+ _clusterId = (String)params.get("cluster");
+ _agentIp = (String)params.get("ipaddress"); // was agentIp
_name = name;
-
- _clusterGuid = (String) params.get("cluster.guid");
- _username = (String) params.get("url");
- _password = (String) params.get("password");
- _username = (String) params.get("username");
+
+ _clusterGuid = (String)params.get("cluster.guid");
+ _username = (String)params.get("url");
+ _password = (String)params.get("password");
+ _username = (String)params.get("username");
_configureCalled = true;
}
@@ -1659,7 +1660,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
// at least have tried _retry times, this is to coordinate with system
// VM patching/rebooting time that may need
int retry = _retry;
- while (System.currentTimeMillis() - startTick <= _ops_timeout || --retry > 0) {
+ while (System.currentTimeMillis() - startTick <= _opsTimeout || --retry > 0) {
SocketChannel sch = null;
try {
s_logger.info("Trying to connect to " + ipAddress);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
index 48c789d..b3bd3b3 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
@@ -42,7 +42,7 @@ public class BridgeVifDriver extends VifDriverBase {
private static final Logger s_logger = Logger.getLogger(BridgeVifDriver.class);
private int _timeout;
- private static final Object _vnetBridgeMonitor = new Object();
+ private final Object _vnetBridgeMonitor = new Object();
private String _modifyVlanPath;
private String _modifyVxlanPath;
private String bridgeNameSchema;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
index 6f6fbc3..fdaaeb3 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
@@ -31,7 +31,7 @@ import com.cloud.utils.script.Script;
public class KVMHABase {
private static final Logger s_logger = Logger.getLogger(KVMHABase.class);
private long _timeout = 60000; /* 1 minutes */
- protected static String _heartBeatPath;
+ protected static String s_heartBeatPath;
protected long _heartBeatUpdateTimeout = 60000;
protected long _heartBeatUpdateFreq = 60000;
protected long _heartBeatUpdateMaxRetry = 3;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
index 02312ce..c2af191 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
@@ -44,7 +44,7 @@ public class KVMHAChecker extends KVMHABase implements Callable<Boolean> {
List<Boolean> results = new ArrayList<Boolean>();
for (NfsStoragePool pool : _pools) {
- Script cmd = new Script(_heartBeatPath, _heartBeatCheckerTimeout, s_logger);
+ Script cmd = new Script(s_heartBeatPath, _heartBeatCheckerTimeout, s_logger);
cmd.add("-i", pool._poolIp);
cmd.add("-p", pool._poolMountSourcePath);
cmd.add("-m", pool._mountDestPath);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
index 58ba808..4628fae 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
@@ -42,7 +42,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
this._storagePool.put(pool._poolUUID, pool);
}
this._hostIP = host;
- KVMHABase._heartBeatPath = scriptPath;
+ KVMHABase.s_heartBeatPath = scriptPath;
}
public void addStoragePool(NfsStoragePool pool) {
@@ -109,7 +109,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
String result = null;
for (int i = 0; i < 5; i++) {
- Script cmd = new Script(_heartBeatPath, _heartBeatUpdateTimeout, s_logger);
+ Script cmd = new Script(s_heartBeatPath, _heartBeatUpdateTimeout, s_logger);
cmd.add("-i", primaryStoragePool._poolIp);
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
cmd.add("-m", primaryStoragePool._mountDestPath);
@@ -124,7 +124,7 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
if (result != null) {
s_logger.warn("write heartbeat failed: " + result + "; reboot the host");
- Script cmd = new Script(_heartBeatPath, _heartBeatUpdateTimeout, s_logger);
+ Script cmd = new Script(s_heartBeatPath, _heartBeatUpdateTimeout, s_logger);
cmd.add("-i", primaryStoragePool._poolIp);
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
cmd.add("-m", primaryStoragePool._mountDestPath);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
index fe2fb5d..2f12d21 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
@@ -31,7 +31,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
private boolean _osType = false;
private boolean _domainTypeKVM = false;
private boolean _emulatorFlag = false;
- private boolean _archTypex86_64 = false;
+ private boolean _archTypex8664 = false;
private final StringBuffer _emulator = new StringBuffer();
private final StringBuffer _capXML = new StringBuffer();
private static final Logger s_logger = Logger.getLogger(LibvirtCapXMLParser.class);
@@ -50,7 +50,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
} else if (qName.equalsIgnoreCase("emulator")) {
_emulatorFlag = false;
} else if (qName.equalsIgnoreCase("arch")) {
- _archTypex86_64 = false;
+ _archTypex8664 = false;
} else if (_host) {
_capXML.append("<").append("/").append(qName).append(">");
}
@@ -81,7 +81,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
} else if (qName.equalsIgnoreCase("arch")) {
for (int i = 0; i < attributes.getLength(); i++) {
if (attributes.getQName(i).equalsIgnoreCase("name") && attributes.getValue(i).equalsIgnoreCase("x86_64")) {
- _archTypex86_64 = true;
+ _archTypex8664 = true;
}
}
} else if (qName.equalsIgnoreCase("domain")) {
@@ -90,7 +90,7 @@ public class LibvirtCapXMLParser extends LibvirtXMLParser {
_domainTypeKVM = true;
}
}
- } else if (qName.equalsIgnoreCase("emulator") && _domainTypeKVM && _archTypex86_64) {
+ } else if (qName.equalsIgnoreCase("emulator") && _domainTypeKVM && _archTypex8664) {
_emulatorFlag = true;
_emulator.delete(0, _emulator.length());
} else if (_host) {