From c3c15b843556386c1f9b05f173a92a0e5ebbdba7 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Mon, 16 May 2011 09:29:12 -0700 Subject: [PATCH] Added some annotations for logging commands --- api/src/com/cloud/agent/api/LogLevel.java | 61 +++++++++++++++++++ .../com/cloud/resource/ResourceManager.java | 22 +++++++ .../cloud/resource/ResourceManagerImpl.java | 54 ++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 api/src/com/cloud/agent/api/LogLevel.java create mode 100644 server/src/com/cloud/resource/ResourceManager.java create mode 100644 server/src/com/cloud/resource/ResourceManagerImpl.java diff --git a/api/src/com/cloud/agent/api/LogLevel.java b/api/src/com/cloud/agent/api/LogLevel.java new file mode 100644 index 00000000000..ad6b50d6ede --- /dev/null +++ b/api/src/com/cloud/agent/api/LogLevel.java @@ -0,0 +1,61 @@ +/** + * 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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.agent.api; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +/** + * Specifies the log level we should log the command in. + */ +@Target({ TYPE, FIELD }) +@Retention(RUNTIME) +public @interface LogLevel { + public enum Log4jLevel { + Off(Level.OFF), + Trace(Level.TRACE), + Debug(Level.DEBUG), + Info(Level.INFO), + Warn(Level.WARN), + Error(Level.ERROR), + Fatal(Level.FATAL); + + Level _level; + + private Log4jLevel(Level level) { + _level = level; + } + + public void log(Logger logger, String msg) { + logger.log(_level, msg); + } + + public boolean enabled(Logger logger) { + return logger.isEnabledFor(_level); + } + } + + Log4jLevel level() default Log4jLevel.Debug; +} diff --git a/server/src/com/cloud/resource/ResourceManager.java b/server/src/com/cloud/resource/ResourceManager.java new file mode 100644 index 00000000000..0bd9d3e5529 --- /dev/null +++ b/server/src/com/cloud/resource/ResourceManager.java @@ -0,0 +1,22 @@ +/** + * 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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.resource; + +public interface ResourceManager { + +} diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java new file mode 100644 index 00000000000..3719bb46b20 --- /dev/null +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -0,0 +1,54 @@ +/** + * 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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.resource; + +import java.util.Map; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; + +import com.cloud.utils.component.Manager; + +@Local({ ResourceManager.class, ResourceService.class }) +public class ResourceManagerImpl implements ResourceManager, Manager { + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean start() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean stop() { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getName() { + // TODO Auto-generated method stub + return null; + } + +}