Context.java

Index Score
org.limewire.mojito
FrostWire

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DECL_COMMENTSComments in declarations
EXITSProcedure exits
JAVA0143JAVA0143 Synchronized method
FUNCTIONSNumber of function declarations
RETURNSNumber of return points from functions
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
SIZESize of the file in bytes
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
INTERFACE_COMPLEXITYInterface complexity
COMMENTSComment lines
CYCLOMATICCyclomatic complexity
BLOCKSNumber of blocks
LINESNumber of lines in the source file
BLOCK_COMMENTNumber of block comment lines
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
LOGICAL_LINESNumber of statements
PROGRAM_LENGTHHalstead program length
OPERANDSNumber of operands
ELOCEffective lines of code
LOCLines of code
LINE_COMMENTNumber of line comments
COMPARISONSNumber of comparison operators
PARAMSNumber of formal parameter declarations
EXEC_COMMENTSComments in executable code
WHITESPACENumber of whitespace lines
JAVA0179JAVA0179 Local variable hides visible field
DOC_COMMENTNumber of javadoc comment lines
JAVA0034JAVA0034 Missing braces in if statement
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
UNIQUE_OPERATORSNumber of unique operators
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0109JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0173JAVA0173 Unused method parameter
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
LOOPSNumber of loops
JAVA0145JAVA0145 Tab character used in source file
/* * Mojito Distributed Hash Table (Mojito DHT) * Copyright (C) 2006-2007 LimeWire LLC * * This program 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 2 of the License, or * (at your option) 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, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package org.limewire.mojito; import java.io.File; import java.io.IOException; import java.math.BigInteger; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.PublicKey; import java.security.SignatureException; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.limewire.mojito.concurrent.DHTExecutorService; import org.limewire.mojito.concurrent.DHTFuture; import org.limewire.mojito.concurrent.DHTFutureListener; import org.limewire.mojito.concurrent.DefaultDHTExecutorService; import org.limewire.mojito.concurrent.FixedDHTFuture; import org.limewire.mojito.db.DHTValue; import org.limewire.mojito.db.DHTValueEntity; import org.limewire.mojito.db.DHTValueFactoryManager; import org.limewire.mojito.db.Database; import org.limewire.mojito.db.DatabaseCleaner; import org.limewire.mojito.db.EvictorManager; import org.limewire.mojito.db.Storable; import org.limewire.mojito.db.StorableModelManager; import org.limewire.mojito.db.StorablePublisher; import org.limewire.mojito.db.impl.DatabaseImpl; import org.limewire.mojito.exceptions.NotBootstrappedException; import org.limewire.mojito.io.MessageDispatcher; import org.limewire.mojito.io.MessageDispatcherFactory; import org.limewire.mojito.io.MessageDispatcherFactoryImpl; import org.limewire.mojito.io.MessageDispatcher.MessageDispatcherEvent; import org.limewire.mojito.io.MessageDispatcher.MessageDispatcherListener; import org.limewire.mojito.io.MessageDispatcher.MessageDispatcherEvent.EventType; import org.limewire.mojito.manager.BootstrapManager; import org.limewire.mojito.manager.FindNodeManager; import org.limewire.mojito.manager.FindValueManager; import org.limewire.mojito.manager.GetValueManager; import org.limewire.mojito.manager.PingManager; import org.limewire.mojito.manager.StoreManager; import org.limewire.mojito.messages.DHTMessage; import org.limewire.mojito.messages.MessageFactory; import org.limewire.mojito.messages.MessageHelper; import org.limewire.mojito.messages.PingRequest; import org.limewire.mojito.messages.RequestMessage; import org.limewire.mojito.result.BootstrapResult; import org.limewire.mojito.result.FindNodeResult; import org.limewire.mojito.result.FindValueResult; import org.limewire.mojito.result.PingResult; import org.limewire.mojito.result.StoreResult; import org.limewire.mojito.routing.BucketRefresher; import org.limewire.mojito.routing.Contact; import org.limewire.mojito.routing.RouteTable; import org.limewire.mojito.routing.Vendor; import org.limewire.mojito.routing.Version; import org.limewire.mojito.routing.RouteTable.PurgeMode; import org.limewire.mojito.routing.RouteTable.SelectMode; import org.limewire.mojito.routing.impl.LocalContact; import org.limewire.mojito.routing.impl.RouteTableImpl; import org.limewire.mojito.security.SecurityTokenHelper; import org.limewire.mojito.settings.ContextSettings; import org.limewire.mojito.settings.KademliaSettings; import org.limewire.mojito.statistics.DHTStats; import org.limewire.mojito.statistics.DHTStatsManager; import org.limewire.mojito.statistics.DatabaseStatisticContainer; import org.limewire.mojito.statistics.GlobalLookupStatisticContainer; import org.limewire.mojito.statistics.NetworkStatisticContainer; import org.limewire.mojito.statistics.RoutingStatisticContainer; import org.limewire.mojito.util.ContactUtils; import org.limewire.mojito.util.CryptoUtils; import org.limewire.mojito.util.DHTSizeEstimator; import org.limewire.mojito.util.HostFilter; import org.limewire.security.MACCalculatorRepositoryManager; import org.limewire.security.SecurityToken; import org.limewire.service.ErrorService; /** * The Context is the heart of Mojito where everything comes * together. */ public class Context implements MojitoDHT, RouteTable.ContactPinger { private static final Log LOG = LogFactory.getLog(Context.class); /** * The name of this Mojito instance */ private final String name; private final StorablePublisher valuePublisher; private final DatabaseCleaner databaseCleaner; private volatile boolean bucketRefresherDisabled = false; private final BucketRefresher bucketRefresher; private final PingManager pingManager; private final FindNodeManager findNodeManager; private final FindValueManager findValueManager; private final StoreManager storeManager; private final BootstrapManager bootstrapManager; private final GetValueManager getValueManager; private final DHTStats stats; private final NetworkStatisticContainer networkStats; private final GlobalLookupStatisticContainer globalLookupStats; private final DatabaseStatisticContainer databaseStats; private volatile KeyPair keyPair; private volatile Database database; private volatile RouteTable routeTable; private volatile MessageDispatcher messageDispatcher; private volatile MessageHelper messageHelper; private volatile DHTSizeEstimator estimator; /** The ExecutorService we're using to schedule tasks */ private volatile DHTExecutorService executorService; /** The provider interface to create SecurityTokens */ private volatile SecurityToken.TokenProvider tokenProvider; /** Manager of repositories of MAC Calculators */ private volatile MACCalculatorRepositoryManager MACCalculatorRepositoryManager; private final SecurityTokenHelper tokenHelper; private final DHTValueFactoryManager factoryManager = new DHTValueFactoryManager(); private final StorableModelManager publisherManager = new StorableModelManager(); private final EvictorManager evictorManager = new EvictorManager(); private volatile HostFilter hostFilter = null; /** * Constructor to create a new Context */ Context(String name, Vendor vendor, Version version, boolean firewalled) { this.name = name; PublicKey masterKey = null; try { File file = new File(ContextSettings.MASTER_KEY.getValue()); if (file.exists() && file.isFile()) { masterKey = CryptoUtils.loadPublicKey(file); } } catch (InvalidKeyException e) { LOG.debug("InvalidKeyException", e); } catch (SignatureException e) { LOG.debug("SignatureException", e); } catch (IOException e) { LOG.debug("IOException", e); } keyPair = new KeyPair(masterKey, null); executorService = new DefaultDHTExecutorService(getName()); MACCalculatorRepositoryManager = new MACCalculatorRepositoryManager(); tokenProvider = new SecurityToken.AddressSecurityTokenProvider(MACCalculatorRepositoryManager); tokenHelper = new SecurityTokenHelper(this); setRouteTable(null); setDatabase(null, false); // Init the Stats stats = DHTStatsManager.getInstance(getLocalNodeID()); networkStats = new NetworkStatisticContainer(getLocalNodeID()); globalLookupStats = new GlobalLookupStatisticContainer(getLocalNodeID()); databaseStats = new DatabaseStatisticContainer(getLocalNodeID()); setMessageDispatcher(null); messageHelper = new MessageHelper(this); valuePublisher = new StorablePublisher(this); databaseCleaner = new DatabaseCleaner(this); bucketRefresher = new BucketRefresher(this); pingManager = new PingManager(this); findNodeManager = new FindNodeManager(this); findValueManager = new FindValueManager(this); storeManager = new StoreManager(this); bootstrapManager = new BootstrapManager(this); getValueManager = new GetValueManager(this); getLocalNode().setVendor(vendor); getLocalNode().setVersion(version); getLocalNode().setFirewalled(firewalled); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getName() */ public String getName() { return name; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getDHTStats() */ public DHTStats getDHTStats() { return stats; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getVendor() */ public Vendor getVendor() { return getLocalNode().getVendor(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getVersion() */ public Version getVersion() { return getLocalNode().getVersion(); } /** * Returns the master public key */ public PublicKey getPublicKey() { KeyPair keyPair = this.keyPair; if (keyPair != null) { return keyPair.getPublic(); } return null; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#getKeyPair() */ public KeyPair getKeyPair() { return keyPair; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#setKeyPair(java.security.KeyPair) */ public void setKeyPair(KeyPair keyPair) { this.keyPair = keyPair; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getLocalNode() */ public LocalContact getLocalNode() { return (LocalContact)getRouteTable().getLocalNode(); } /** * Generates a new random Node ID for the local Node, * rebuild the routing table with this new ID and purge * the database (it doesn't make sense to keep the key-values * from our old node ID). * * WARNING: Meant to be called only by BootstrapManager * or MojitoFactory! */ public void changeNodeID() { KUID newID = KUID.createRandomID(); if (LOG.isInfoEnabled()) { LOG.info("Changing local Node ID from " + getLocalNodeID() + " to " + newID); } setLocalNodeID(newID); purgeDatabase(); } /** * Rebuilds the routeTable with the given local node ID. * This will effectively clear the route table and * re-add any previous node in the MRS order. * * @param localNodeID the local node's KUID */ private void setLocalNodeID(KUID localNodeID) { RouteTable routeTable = getRouteTable(); synchronized (routeTable) { // Change the Node ID getLocalNode().setNodeID(localNodeID); routeTable.purge(PurgeMode.PURGE_CONTACTS, PurgeMode.MERGE_BUCKETS, PurgeMode.STATE_TO_UNKNOWN); assert(getLocalNode().equals(routeTable.get(localNodeID))); } getStorableModelManager().handleContactChange(this); } /** * Returns true if the given Contact is equal to the * local Node. */ public boolean isLocalNode(Contact node) { return node.equals(getLocalNode()); } /** * Returns true if the given KUID and SocketAddress are * equal to local Node's KUID and SocketAddress (contact address) */ public boolean isLocalNode(KUID nodeId, SocketAddress addr) { return isLocalNodeID(nodeId) && isLocalContactAddress(addr); } /** * Returns true if the given KUID is equal to local Node's KUID */ public boolean isLocalNodeID(KUID nodeId) { return nodeId != null && nodeId.equals(getLocalNodeID()); } /** * Returns true if the given SocketAddress is equal to local * Node's SocketAddress */ public boolean isLocalContactAddress(SocketAddress address) { return getContactAddress().equals(address); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getLocalNodeID() */ public KUID getLocalNodeID() { return getLocalNode().getNodeID(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setMessageDispatcher(java.lang.Class) */ public synchronized MessageDispatcher setMessageDispatcher(MessageDispatcherFactory messageDispatcherFactory) { if (isRunning()) { throw new IllegalStateException("Cannot switch MessageDispatcher while " + getName() + " is running"); } if (messageDispatcherFactory == null) { messageDispatcherFactory = new MessageDispatcherFactoryImpl(); } messageDispatcher = messageDispatcherFactory.create(this); messageDispatcher.addMessageDispatcherListener( new NetworkStatisticContainer.Listener(networkStats)); return messageDispatcher; } /** * Returns the MessageDispatcher */ public MessageDispatcher getMessageDispatcher() { // Not synchronized 'cause only called when Mojito is running and // while Mojito is running you cannot change the MessageDispatcher return messageDispatcher; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setRouteTable(com.limegroup.mojito.routing.RouteTable) */ public synchronized void setRouteTable(RouteTable routeTable) { if (isRunning()) { throw new IllegalStateException("Cannot switch RouteTable while " + getName() + " is running"); } if (this.routeTable != null && this.routeTable == routeTable) { if (LOG.isErrorEnabled()) { LOG.error("Cannot set the same instance multiple times"); } //throw new IllegalArgumentException(); return; } if (routeTable == null) { routeTable = new RouteTableImpl(); } routeTable.setContactPinger(this); routeTable.setNotifier(getDHTExecutorService()); routeTable.addRouteTableListener(new RoutingStatisticContainer.Listener()); this.routeTable = routeTable; if (database != null) { purgeDatabase(); } } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getRouteTable() */ public RouteTable getRouteTable() { return routeTable; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setDatabase(com.limegroup.mojito.db.Database) */ public synchronized void setDatabase(Database database) { setDatabase(database, true); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getDatabase() */ public Database getDatabase() { return database; } /** * Sets the Database * * @param database The Database (can be null to use the default Database implemetation) * @param remove Whether or not to remove non local DHTValues */ private synchronized void setDatabase(Database database, boolean remove) { if (isRunning()) { throw new IllegalStateException("Cannot switch Database while " + getName() + " is running"); } if (this.database != null && this.database == database) { if (LOG.isDebugEnabled()) { LOG.debug("Cannot set the same instance multiple times"); } return; } if (database == null) { database = new DatabaseImpl(); } this.database = database; purgeDatabase(); } /** * Purge Database makes sure the originator of all local DHTValues * is the LocalContact and that all non local DHTValues get removed * from the Database if they're expired or if <tt>remove</tt> is * true. * * @param remove Whether or not to remove non local DHTValues */ private void purgeDatabase() { // We're assuming the Node IDs are totally random so // chances are slim to none that we're responseible // for the values again. Even if we are there's no way // to test it until we've fully re-bootstrapped in // which case the other guys will send us the values // anyways as from their perspective we're just a new // node. database.clear(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setMessageFactory(com.limegroup.mojito.messages.MessageFactory) */ public synchronized void setMessageFactory(MessageFactory messageFactory) { if (isRunning()) { throw new IllegalStateException("Cannot switch MessageFactory while " + getName() + " is running"); } messageHelper.setMessageFactory(messageFactory); } /** * Returns the current MessageFactory. In most cases you want to use * the MessageHelper instead which is a simplified version of the * MessageFactory. */ public MessageFactory getMessageFactory() { // Not synchronized 'cause only called when Mojito is running and // while Mojito is running you cannot change the MessageHelper return messageHelper.getMessageFactory(); } /** * Sets the MessageHelper */ public synchronized void setMessageHelper(MessageHelper messageHelper) { if (isRunning()) { throw new IllegalStateException("Cannot switch MessageHelper while " + getName() + " is running"); } this.messageHelper = messageHelper; } /** * Returns the current MessageHelper which is a simplified * MessageFactory */ public MessageHelper getMessageHelper() { // Not synchronized 'cause only called when Mojito is running and // while Mojito is running you cannot change the MessageHelper return messageHelper; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setHostFilter(com.limegroup.mojito.util.HostFilter) */ public synchronized void setHostFilter(HostFilter hostFilter) { this.hostFilter = hostFilter; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#getHostFilter() */ public HostFilter getHostFilter() { return hostFilter; } /** * Sets the TokenProvider */ public synchronized void setSecurityTokenProvider(SecurityToken.TokenProvider tokenProvider) { if (isRunning()) { throw new IllegalStateException("Cannot switch TokenProvider while " + getName() + " is running"); } this.tokenProvider = tokenProvider; } /** * Returns the TokenProvider */ public SecurityToken.TokenProvider getSecurityTokenProvider() { return tokenProvider; } public synchronized void setMACCalculatorRepositoryManager(MACCalculatorRepositoryManager manager) { if (isRunning()) { throw new IllegalStateException("Cannot switch MACManager while " + getName() + " is running"); } this.MACCalculatorRepositoryManager = manager; } public MACCalculatorRepositoryManager getMACCalculatorRepositoryManager() { return MACCalculatorRepositoryManager; } /** * Returns the SecurityTokenHelper */ public SecurityTokenHelper getSecurityTokenHelper() { return tokenHelper; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setExternalPort(int) */ public void setExternalPort(int port) { getLocalNode().setExternalPort(port); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getExternalPort() */ public int getExternalPort() { return getLocalNode().getExternalPort(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getContactAddress() */ public SocketAddress getContactAddress() { return getLocalNode().getContactAddress(); } /** * Sets the contact address of the local Node. Effectively * we're maybe only using the port number. */ public void setContactAddress(SocketAddress externalAddress) { getLocalNode().setContactAddress(externalAddress); } /** * Sets the local Node's external address (the address other are * seeing if this Node is behind a NAT router) */ public void setExternalAddress(SocketAddress externalSocketAddress) { boolean changed = getLocalNode().setExternalAddress(externalSocketAddress); if (changed) { getStorableModelManager().handleContactChange(this); } } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getLocalAddress() */ public SocketAddress getLocalAddress() { return getLocalNode().getSourceAddress(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#isFirewalled() */ public boolean isFirewalled() { return getLocalNode().isFirewalled(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#setDHTExecutorService(com.limegroup.mojito.concurrent.DHTExecutorService) * this method is not really used anywhere and not even tested... */ public void setDHTExecutorService(DHTExecutorService executorService) { if (executorService == null) { executorService = new DefaultDHTExecutorService(getName()); } this.executorService = executorService; RouteTable rt = getRouteTable(); if (rt != null) rt.setNotifier(executorService); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#getDHTExecutorService() */ public DHTExecutorService getDHTExecutorService() { return executorService; } /** * Sets whether or not the BucketRefresher should be disabled */ public synchronized void setBucketRefresherDisabled(boolean bucketRefresherDisabled) { if (isRunning()) { throw new IllegalStateException("Cannot disable BucketRefresher while " + getName() + " is running"); } this.bucketRefresherDisabled = bucketRefresherDisabled; } /** * Returns whether or not the BucketRefresher is disabled */ public boolean isBucketRefresherDisabled() { return bucketRefresherDisabled; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#getDHTValueFactoryManager() */ public DHTValueFactoryManager getDHTValueFactoryManager() { return factoryManager; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#getStorableModelManager() */ public StorableModelManager getStorableModelManager() { return publisherManager; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#getEvictorManager() */ public EvictorManager getEvictorManager() { return evictorManager; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#isRunning() */ public boolean isRunning() { MessageDispatcher messageDispatcher = this.messageDispatcher; if (messageDispatcher != null) { return messageDispatcher.isRunning(); } return false; } /** * Returns the BootstrapManager */ public BootstrapManager getBootstrapManager() { return bootstrapManager; } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#isBootstrapping() */ public boolean isBootstrapping() { return isRunning() && bootstrapManager.isBootstrapping(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#isBootstrapped() */ public boolean isBootstrapped() { return isRunning() && bootstrapManager.isBootstrapped(); } /** * A helper method to set whether or not the Mojito DHT * instance is bootstrapped. * * Note: This method is primarily for testing. */ public synchronized void setBootstrapped(boolean bootstrapped) { bootstrapManager.setBootstrapped(bootstrapped); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#isBound() */ public boolean isBound() { MessageDispatcher messageDispatcher = this.messageDispatcher; if (messageDispatcher != null) { return messageDispatcher.isBound(); } return false; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#bind(int) */ public synchronized void bind(int port) throws IOException { bind(new InetSocketAddress(port)); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#bind(java.net.InetAddress, int) */ public synchronized void bind(InetAddress addr, int port) throws IOException { bind(new InetSocketAddress(addr, port)); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#bind(java.net.SocketAddress) */ public synchronized void bind(SocketAddress bindAddr) throws IOException { if (isBound()) { throw new IOException(getName() + " is already bound"); } final int port = ((InetSocketAddress)bindAddr).getPort(); if (port == 0) { throw new IOException("Cannot bind Socket to Port " + port); } if(LOG.isDebugEnabled()) { LOG.debug("Binding " + getName() + " to address: " + bindAddr); } // If we not firewalled and the external port has not // been set yet then set it to the same port as the // local address. if (!isFirewalled() && getExternalPort() == 0) { setExternalPort(port); } getLocalNode().setSourceAddress(bindAddr); getLocalNode().nextInstanceID(); messageDispatcher.bind(bindAddr); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#start() */ public synchronized void start() { if (!isBound()) { throw new IllegalStateException(getName() + " is not bound"); } if (isRunning()) { if(LOG.isDebugEnabled()) { LOG.debug(getName() + " is already running!"); } return; } // Startup the local Node getLocalNode().shutdown(false); executorService.start(); pingManager.init(); findNodeManager.init(); findValueManager.init(); estimator = new DHTSizeEstimator(); messageDispatcher.start(); if (!isBucketRefresherDisabled()) { bucketRefresher.start(); } valuePublisher.start(); databaseCleaner.start(); } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#stop() */ public synchronized void stop() { if (!isRunning()) { if (LOG.isDebugEnabled()) { LOG.debug(getName() + " is not running"); } return; } if(LOG.isDebugEnabled()) { LOG.debug("Stopping " + getName()); } // Stop the Bucket refresher and the value manager bucketRefresher.stop(); valuePublisher.stop(); databaseCleaner.stop(); // Shutdown the local Node Contact localNode = getLocalNode(); localNode.shutdown(true); if (isBootstrapped() && !isFirewalled() && ContextSettings.SEND_SHUTDOWN_MESSAGE.getValue()) { // We're nice guys and send shutdown messages to the 2*k-closest // Nodes which should help to reduce the overall latency. int m = ContextSettings.SHUTDOWN_MESSAGES_MULTIPLIER.getValue(); int k = KademliaSettings.REPLICATION_PARAMETER.getValue(); int count = m*k; if (LOG.isDebugEnabled()) { LOG.debug("Sending shutdown message to " + count + " Nodes"); } Collection<Contact> nodes = getRouteTable().select( localNode.getNodeID(), count, SelectMode.ALIVE); final CountDownLatch latch = new CountDownLatch(nodes.size()); MessageDispatcherListener listener = new MessageDispatcherListener() { public void handleMessageDispatcherEvent(MessageDispatcherEvent evt) { if (evt.getEventType() != EventType.MESSAGE_SENT) { return; } DHTMessage message = evt.getMessage(); if (!(message instanceof PingRequest)) { return; } latch.countDown(); } }; try { // Register the listener messageDispatcher.addMessageDispatcherListener(listener); // Send the shutdown Messages for (Contact node : nodes) { if (!node.equals(localNode)) { // We are not interested in the responses as we're going // to shutdown. Send pings without a response handler. RequestMessage request = getMessageFactory() .createPingRequest(localNode, node.getContactAddress()); try { messageDispatcher.send(node, request, null); } catch (IOException err) { LOG.error("IOException", err); } } } // Wait for the messages being sent try { if (!latch.await(1000L, TimeUnit.MILLISECONDS)) { LOG.info("Not all shutdown messages were sent"); } } catch (InterruptedException err) { LOG.error("InterruptedException", err); } } finally { // Remove the listener messageDispatcher.removeMessageDispatcherListener(listener); } } messageDispatcher.stop(); executorService.stop(); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#close() */ public synchronized void close() { stop(); messageDispatcher.close(); bootstrapManager.setBootstrapped(false); if (estimator != null) { estimator.clear(); } setExternalPort(0); } /** * Returns a Set of active Contacts sorted by most recently * seen to least recently seen */ private Set<Contact> getActiveContacts() { Set<Contact> nodes = new LinkedHashSet<Contact>(); Collection<Contact> active = getRouteTable().getActiveContacts(); active = ContactUtils.sort(active); nodes.addAll(active); nodes.remove(getLocalNode()); return nodes; } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#ping() */ public DHTFuture<PingResult> findActiveContact() { return pingManager.ping(getActiveContacts()); } /** * Tries to ping a Set of hosts */ public DHTFuture<PingResult> ping(Set<? extends SocketAddress> hosts) { return pingManager.pingAddresses(hosts); } /** * Pings the DHT node with the given SocketAddress. * * @param address The address of the remote Node */ public DHTFuture<PingResult> ping(SocketAddress address) { return pingManager.ping(address); } /** * Pings the given Node */ public DHTFuture<PingResult> ping(Contact node) { return pingManager.ping(node); } public void ping(final Contact node, final DHTFutureListener<PingResult> listener) { Runnable command = new Runnable() { public void run() { try { DHTFuture<PingResult> future = ping(node); if (listener != null) { future.addDHTFutureListener(listener); } } catch (RejectedExecutionException err) { ErrorService.error(err); } } }; getDHTExecutorService().execute(command); } /** * Sends a special collision test Ping to the given Node */ public DHTFuture<PingResult> collisionPing(Contact node) { return pingManager.collisionPing(node); } /** * Sends a special collision test Ping to the given Node */ public DHTFuture<PingResult> collisionPing(Set<? extends Contact> nodes) { return pingManager.collisionPing(nodes); } /** * A helper method that throws a NotBootstrappedException if * Mojito is not bootstrapped */ private void throwExceptionIfNotBootstrapped(String operation) throws NotBootstrappedException { if (!isBootstrapped()) { if (ContextSettings.THROW_EXCEPTION_IF_NOT_BOOTSTRAPPED.getValue()) { throw new NotBootstrappedException(getName(), operation); } else if (LOG.isInfoEnabled()) { LOG.info(NotBootstrappedException.getErrorMessage(getName(), operation)); } } } /* * (non-Javadoc) * @see org.limewire.mojito.MojitoDHT#get(org.limewire.mojito.db.EntityKey) */ public DHTFuture<FindValueResult> get(EntityKey entityKey) { if (entityKey.isLookupKey()) { throwExceptionIfNotBootstrapped("get()"); return findValueManager.lookup(entityKey); } else { return getValueManager.get(entityKey); } } /** * Starts a Node lookup for the given KUID */ public DHTFuture<FindNodeResult> lookup(KUID lookupId) { return findNodeManager.lookup(lookupId); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#bootstrap(com.limegroup.mojito.routing.Contact) */ public DHTFuture<BootstrapResult> bootstrap(Contact node) { return bootstrapManager.bootstrap(node); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#bootstrap(com.limegroup.mojito.routing.Contact) */ public DHTFuture<BootstrapResult> bootstrap(SocketAddress dst) { return bootstrapManager.bootstrap(Collections.singleton(dst)); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#put(com.limegroup.mojito.KUID, com.limegroup.mojito.db.DHTValue) */ public DHTFuture<StoreResult> put(KUID key, DHTValue value) { return put(DHTValueEntity.createFromValue(this, key, value)); } /** * @param entity The value to store * @param immediateStore Whether or not to store the value immediately */ public DHTFuture<StoreResult> put(DHTValueEntity entity) { if (!isRunning()) { throw new IllegalStateException(getName() + " is not running"); } // If we're bootstrapped then store the value immediately // or let the DHTValueManager do its work if (isBootstrapped()) { return store(entity); // And if we're not bootstrapped then return a fake Future // and let the DHTValueManager do its work once we're bootstrapped } else { String operation = (entity.getValue().size() == 0) ? "remove()" : "put()"; Exception ex = new NotBootstrappedException(getName(), operation); return new FixedDHTFuture<StoreResult>(ex); } } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#remove(com.limegroup.mojito.KUID) */ public DHTFuture<StoreResult> remove(KUID key) { // To remove a KeyValue you just store an empty value! return put(key, DHTValue.EMPTY_VALUE); } /** * Stores the given Storable */ public DHTFuture<StoreResult> store(Storable storable) { return store(DHTValueEntity.createFromStorable(this, storable)); } /** * Stores the given DHTValue */ public DHTFuture<StoreResult> store(DHTValueEntity entity) { return store(Collections.singleton(entity)); } /** * Stores a Collection of DHTValue(s). All values must have the same * valueId! */ public DHTFuture<StoreResult> store(Collection<? extends DHTValueEntity> values) { throwExceptionIfNotBootstrapped("store()"); return storeManager.store(values); } /** * Stores a Collection of DHTValue(s) at the given Node. * All values must have the same valueId! */ public DHTFuture<StoreResult> store(Contact node, SecurityToken securityToken, Collection<? extends DHTValueEntity> values) { return storeManager.store(node, securityToken, values); } /* * (non-Javadoc) * @see com.limegroup.mojito.MojitoDHT#size() */ public synchronized BigInteger size() { if (!isRunning()) { return BigInteger.ZERO; } return estimator.getEstimatedSize(getRouteTable()); } /** * Adds the approximate DHT size as returned by a remote Node. * The average of the remote DHT sizes is incorporated into * our local computation. */ public void addEstimatedRemoteSize(BigInteger remoteSize) { estimator.addEstimatedRemoteSize(remoteSize); } /** * Updates the approximate DHT size based on the given Contacts */ public void updateEstimatedSize(Collection<? extends Contact> nodes) { estimator.updateSize(nodes); } /** * Returns the StatisticsContainer for Network statistics */ public NetworkStatisticContainer getNetworkStats() { return networkStats; } /** * Returns the StatisticsContainer for lookup statistics */ public GlobalLookupStatisticContainer getGlobalLookupStats() { return globalLookupStats; } /** * Returns the StatisticsContainer for Database statistics */ public DatabaseStatisticContainer getDatabaseStats() { return databaseStats; } public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("Local Node: ").append(getLocalNode()).append("\n"); buffer.append("Is running: ").append(isRunning()).append("\n"); buffer.append("Is bootstrapped/ing: ").append(isBootstrapped()).append("/") .append(isBootstrapping()).append("\n"); buffer.append("Database Size (Keys): ").append(getDatabase().getKeyCount()).append("\n"); buffer.append("Database Size (Values): ").append(getDatabase().getValueCount()).append("\n"); buffer.append("RouteTable Size: ").append(getRouteTable().size()).append("\n"); buffer.append("Estimated DHT Size: ").append(size()).append("\n"); return buffer.toString(); } }

The table below shows all metrics for Context.java.

MetricValueDescription
BLOCKS155.00Number of blocks
BLOCK_COMMENT191.00Number of block comment lines
COMMENTS397.00Comment lines
COMMENT_DENSITY 0.77Comment density
COMPARISONS79.00Number of comparison operators
CYCLOMATIC156.00Cyclomatic complexity
DECL_COMMENTS90.00Comments in declarations
DOC_COMMENT171.00Number of javadoc comment lines
ELOC515.00Effective lines of code
EXEC_COMMENTS20.00Comments in executable code
EXITS158.00Procedure exits
FUNCTIONS90.00Number of function declarations
HALSTEAD_DIFFICULTY68.32Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY177.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 1.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 2.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA010828.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 2.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011027.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 1.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 1.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA014318.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 1.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 4.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1236.00Number of lines in the source file
LINE_COMMENT35.00Number of line comments
LOC660.00Lines of code
LOGICAL_LINES347.00Number of statements
LOOPS 0.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1503.00Number of operands
OPERATORS2979.00Number of operators
PARAMS56.00Number of formal parameter declarations
PROGRAM_LENGTH4482.00Halstead program length
PROGRAM_VOCAB576.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS121.00Number of return points from functions
SIZE40852.00Size of the file in bytes
UNIQUE_OPERANDS528.00Number of unique operands
UNIQUE_OPERATORS48.00Number of unique operators
WHITESPACE179.00Number of whitespace lines