Skip to content

Commit

Permalink
Merge pull request #4124 from Cousjava/PAYARA-4034-cleanup-amx-core
Browse files Browse the repository at this point in the history
PAYARA-4034 Cleanup sonar warnings for nucleus/common/amx-core
  • Loading branch information
Cousjava authored Aug 20, 2019
2 parents 9f3f371 + 1346755 commit a75c37f
Show file tree
Hide file tree
Showing 158 changed files with 3,080 additions and 6,531 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2018] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2018-2019] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -45,7 +45,6 @@

import fish.payara.admin.amx.config.AMXConfiguration;
import java.beans.PropertyChangeEvent;
import java.util.Collections;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.glassfish.admin.mbeanserver.BootAMX;
Expand All @@ -58,8 +57,8 @@
import org.jvnet.hk2.config.UnprocessedChangeEvents;

/**
*
* @author jonathan
* Service to boot AMX if it is enabled
* @author jonathan coustick
* @since 4.1.2.172
*/
@Service(name="amx-boot-service")
Expand All @@ -73,7 +72,6 @@ public class AMXBootService implements ConfigListener {
ServiceLocator habitat;

private boolean enabled;
private BootAMX bootAMX;

@PostConstruct
public void postConstruct(){
Expand All @@ -85,7 +83,7 @@ public void postConstruct(){
}

private void startup(){
bootAMX = habitat.getService(BootAMX.class);
BootAMX bootAMX = habitat.getService(BootAMX.class);
bootAMX.bootAMX();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,3 @@ where the interface FooBar is a sub-interface of {@link org.glassfish.admin.amx.
/** child type, derived automatically by default for the normal naming pattern */
String type() default "";
}







Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,3 @@
public @interface Description {
public String value() default "";
}







Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,3 @@
@Taxonomy(stability = Stability.NOT_AN_INTERFACE)
public @interface ManagedAttribute {
}







Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@
@Taxonomy(stability = Stability.NOT_AN_INTERFACE)
public @interface ManagedOperation {
public int impact() default MBeanOperationInfo.UNKNOWN;
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,3 @@
/** true if null may be passed */
public boolean optional() default false;
}







Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,4 @@
package org.glassfish.admin.amx.annotation;

import org.glassfish.external.arc.Taxonomy;
import org.glassfish.external.arc.Stability;



import org.glassfish.external.arc.Stability;
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,3 @@ public Object[] bulkInvoke(final ObjectName[] objectNames,
final Object[] args, final String[] types);

}


Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,3 @@ to DomainConfig using getDomain().as(DomainConfig.class).
@Description("Return a Map of all non-compliant MBeans (MBeans might no longer be registered). The List<String> contains all issues with that MBean")
public Map<ObjectName, List<String>> getComplianceFailures();
}














Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,3 @@ public interface Ext extends AMXProxy, Singleton, Utility
public Realms getRealms();

}

















Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2019] Payara Foundation and/or affiliates

package org.glassfish.admin.amx.base;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.*;
import org.glassfish.admin.amx.util.AMXLoggerInfo;
import org.glassfish.admin.amx.core.AMXMBeanMetadata;
import org.glassfish.admin.amx.core.Util;
import org.glassfish.admin.amx.util.jmx.JMXUtil;
Expand All @@ -53,17 +58,16 @@
import org.glassfish.external.arc.Taxonomy;

/**
* Tracks the entire MBean parent/child hierarachy so that individual MBeans
* Tracks the entire MBean parent/child hierarchy so that individual MBeans
* need not do so. Can supply parents and children of any MBean, used by all AMX
* implementations.
*/
@Taxonomy(stability = Stability.NOT_AN_INTERFACE)
@AMXMBeanMetadata(singleton = true, globalSingleton = true, leaf = true)
public final class MBeanTracker implements NotificationListener, MBeanRegistration, MBeanTrackerMBean {

private static final Logger LOGGER = AMXLoggerInfo.getLogger();

private static void debug(final Object o) {
System.out.println("" + o);
}
/**
* maps a parent ObjectName to a Set of children
*/
Expand Down Expand Up @@ -112,12 +116,12 @@ public void handleNotification(final Notification notifIn, final Object handback
// first and there's nothing we could do about it.
if (type.equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
if (mEmitMBeanStatus) {
System.out.println("AMX MBean registered: " + objectName);
LOGGER.log(Level.INFO, "AMX MBean registered: {0}", objectName);
}
addChild(objectName);
} else if (type.equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
if (mEmitMBeanStatus) {
System.out.println("AMX MBean UNregistered: " + objectName);
LOGGER.log(Level.INFO, "AMX MBean UNregistered: {0}", objectName);
}
removeChild(objectName);
}
Expand All @@ -140,18 +144,16 @@ public final void postRegister(final Boolean registrationSucceeded) {
if (mServer == null) {
return;
}
if (registrationSucceeded.booleanValue()) {
if (registrationSucceeded) {
try {
mServer.addNotificationListener(JMXUtil.getMBeanServerDelegateObjectName(), this, null, null);
} catch (Exception e) {
throw new RuntimeException("Could not register with MBeanServerDelegate", e);
}
//debug( "MBeanTracker: registered as " + mObjectName );
}
// populate our list
final ObjectName pattern = Util.newObjectNamePattern(mDomain, "");
final Set<ObjectName> names = JMXUtil.queryNames(mServer, pattern, null);
//debug( "MBeanTracker: found MBeans: " + names.size() );
for (final ObjectName o : names) {
addChild(o);
}
Expand All @@ -166,6 +168,7 @@ public final void preDeregister() throws Exception {

@Override
public final void postDeregister() {
//nothing needed here, see preDeregister
}

private boolean isRelevantMBean(final ObjectName child) {
Expand All @@ -181,7 +184,7 @@ private void addChild(final ObjectName child) {
parent = (ObjectName) mServer.getAttribute(child, AMX.ATTR_PARENT);
} catch (final Exception e) {
// nothing to be done, MBean gone missing, badly implemented, etc.
//System.out.println( "No Parent for: " + child );
LOGGER.log(Level.FINE, "No Parent for: {0}", child);
}

if (parent != null) {
Expand All @@ -193,7 +196,6 @@ private void addChild(final ObjectName child) {
mParentChildren.put(parent, children);
}
children.add(child);
//debug( "MBeanTracker: ADDED " + child + " with parent " + parent );
}
}
}
Expand All @@ -209,7 +211,6 @@ private synchronized ObjectName removeChild(final ObjectName child) {
children.remove(child);
if (children.isEmpty()) {
mParentChildren.remove(parent);
//debug( "MBeanTracker: REMOVED " + child + " from parent " + parent );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,3 @@ public interface MBeanTrackerMBean
@ManagedAttribute
public void setEmitMBeanStatus(boolean emit);
}











Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,3 @@ Resolves the path to an ObjectName, then calls ancestors(objectName).
@ManagedOperation(impact=MBeanOperationInfo.INFO)
public String[] dump( final String path );
}







Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,3 @@ have a different Parent (uniqueness invariant within any parent).
@ManagedOperation(impact = MBeanOperationInfo.INFO)
public AMXProxy[] queryDescendants( @Param(name="parentObjectName") ObjectName parentObjectName);
}






Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,3 @@ public interface Realms extends AMXProxy, Utility, Singleton
@ManagedAttribute
public String getAnonymousUser();
}










Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,3 @@ public String getContextRoot(
@Description("Whether the server was started with --debug")
public boolean isStartedInDebugMode();
}










Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,3 @@ The type of Notification emitted by emitNotification().
@ManagedAttribute
public Object[] getAllSortsOfStuff();
}










Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,3 @@
public interface Singleton extends AMXProxy
{
}


Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,3 @@ high availability feature (HADB) is available.
public Map<String, Long> getPerformanceMillis();

}


Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,3 @@ public String validate(
public String getHierarchy();

}
















Loading

0 comments on commit a75c37f

Please sign in to comment.