Java Code Examples for javolution.util.FastList#addAll()

The following examples show how to use javolution.util.FastList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LegionService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public void LegionWhUpdate(Player player) {
	Legion legion = player.getLegion();

	if (legion == null) {
		return;
	}

	FastList<Item> allItems = legion.getLegionWarehouse().getItemsWithKinah();
	allItems.addAll(legion.getLegionWarehouse().getDeletedItems());
	try {
		/**
		 * 1. save items first
		 */
		DAOManager.getDAO(InventoryDAO.class).store(allItems, player.getObjectId(), player.getPlayerAccount().getId(), legion.getLegionId());

		/**
		 * 2. save item stones
		 */
		DAOManager.getDAO(ItemStoneListDAO.class).save(allItems);
	}
	catch (Exception ex) {
		log.error("[LegionService] Exception during periodic saving of legion WH", ex);
	}
}
 
Example 2
Source File: DataStructure.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private List<ValuePart> getValuePartList(DataTreeNodeContainer node)
{
    FastList<ValuePart> parts = new FastList<ValuePart>();
    for(DataTreeNode n : node.getNodes())
    {
        if(n instanceof ValuePart)
            parts.add((ValuePart) n);
        else if(n instanceof DataTreeNodeContainer)
            parts.addAll(getValuePartList((DataTreeNodeContainer) n));
    }
    return parts;
}
 
Example 3
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void removeCongestionListener(CongestionListener listener) {
    synchronized (this) {
        if (!this.congestionListeners.contains(listener))
            return;

        FastList<CongestionListener> newCongestionListeners = new FastList<CongestionListener>();
        newCongestionListeners.addAll(this.congestionListeners);
        newCongestionListeners.remove(listener);
        this.congestionListeners = newCongestionListeners;
    }
}
 
Example 4
Source File: Player.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
/**
 * //TODO probably need to optimize here
 *
 * @return
 */
public FastList<Item> getAllItems() {
	FastList<Item> items = FastList.newInstance();
	items.addAll(this.inventory.getItemsWithKinah());
	if (this.regularWarehouse != null) {
		items.addAll(this.regularWarehouse.getItemsWithKinah());
	}
	if (this.accountWarehouse != null) {
		items.addAll(this.accountWarehouse.getItemsWithKinah());
	}

	for (int petBagId = StorageType.PET_BAG_MIN; petBagId <= StorageType.PET_BAG_MAX; petBagId++) {
		IStorage petBag = getStorage(petBagId);
		if (petBag != null) {
			items.addAll(petBag.getItemsWithKinah());
		}
	}

	for (int houseWhId = StorageType.HOUSE_WH_MIN; houseWhId <= StorageType.HOUSE_WH_MAX; houseWhId++) {
		IStorage cabinet = getStorage(houseWhId);
		if (cabinet != null) {
			items.addAll(cabinet.getItemsWithKinah());
		}
	}

	items.addAll(getEquipment().getEquippedItems());
	return items;
}
 
Example 5
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addCongestionListener(CongestionListener listener) {
    synchronized (this) {
        if (this.congestionListeners.contains(listener))
            return;

        FastList<CongestionListener> newCongestionListeners = new FastList<CongestionListener>();
        newCongestionListeners.addAll(this.congestionListeners);
        newCongestionListeners.add(listener);
        this.congestionListeners = newCongestionListeners;
    }
}
 
Example 6
Source File: PeriodicSaveService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	log.debug("Legion WH update task started.");
	long startTime = System.currentTimeMillis();
	Iterator<Legion> legionsIterator = LegionService.getInstance().getCachedLegionIterator();
	int legionWhUpdated = 0;
	while (legionsIterator.hasNext()) {
		Legion legion = legionsIterator.next();
		FastList<Item> allItems = legion.getLegionWarehouse().getItemsWithKinah();
		allItems.addAll(legion.getLegionWarehouse().getDeletedItems());
		try {
			/**
			 * 1. save items first
			 */
			DAOManager.getDAO(InventoryDAO.class).store(allItems, null, null, legion.getLegionId());

			/**
			 * 2. save item stones
			 */
			DAOManager.getDAO(ItemStoneListDAO.class).save(allItems);
		}
		catch (Exception ex) {
			log.error("Exception during periodic saving of legion WH", ex);
		}

		legionWhUpdated++;
	}
	long workTime = System.currentTimeMillis() - startTime;
	log.debug("Legion WH update: " + workTime + " ms, legions: " + legionWhUpdated + ".");
}
 
Example 7
Source File: HousingService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public FastList<House> getCustomHouses() {
	FastList<House> houses = FastList.newInstance();
	for (List<House> mapHouses : housesByMapId.values()) {
		houses.addAll(mapHouses);
	}
	return houses;
}
 
Example 8
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
public void addManagementEventListener(ManagementEventListener listener) {
	synchronized (this) {
		if (this.managementEventListeners.contains(listener))
			return;

		FastList<ManagementEventListener> newManagementEventListeners = new FastList<ManagementEventListener>();
		newManagementEventListeners.addAll(this.managementEventListeners);
		newManagementEventListeners.add(listener);
		this.managementEventListeners = newManagementEventListeners;
	}
}
 
Example 9
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
public void removeManagementEventListener(ManagementEventListener listener) {
	synchronized (this) {
		if (!this.managementEventListeners.contains(listener))
			return;

		FastList<ManagementEventListener> newManagementEventListeners = new FastList<ManagementEventListener>();
		newManagementEventListeners.addAll(this.managementEventListeners);
		newManagementEventListeners.remove(listener);
		this.managementEventListeners = newManagementEventListeners;
	}
}
 
Example 10
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void removeManagementEventListener(ManagementEventListener listener) {
    synchronized (this) {
        if (!this.managementEventListeners.contains(listener))
            return;

        FastList<ManagementEventListener> newManagementEventListeners = new FastList<ManagementEventListener>();
        newManagementEventListeners.addAll(this.managementEventListeners);
        newManagementEventListeners.remove(listener);
        this.managementEventListeners = newManagementEventListeners;
    }
}
 
Example 11
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Association addServerAssociation(String peerAddress, int peerPort, String serverName, String assocName,
        IpChannelType ipChannelType) throws Exception {
    if (!this.started) {
        throw new Exception(String.format("Management=%s not started", this.name));
    }

    if (peerAddress == null) {
        throw new Exception("Peer address cannot be null");
    }

    if (peerPort < 0) {
        throw new Exception("Peer port cannot be less than 0");
    }

    if (serverName == null) {
        throw new Exception("Server name cannot be null");
    }

    if (assocName == null) {
        throw new Exception("Association name cannot be null");
    }

    synchronized (this) {
        if (this.associations.get(assocName) != null) {
            throw new Exception(String.format("Already has association=%s", assocName));
        }

        Server server = null;

        for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
            Server serverTemp = n.getValue();
            if (serverTemp.getName().equals(serverName)) {
                server = serverTemp;
            }
        }

        if (server == null) {
            throw new Exception(String.format("No Server found for name=%s", serverName));
        }

        for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n
                .getNext()) != end;) {
            Association associationTemp = n.getValue();
            
            if (associationTemp.getServerName().equals(server.getName()) && peerAddress.equals(associationTemp.getPeerAddress()) && associationTemp.getPeerPort() == peerPort) {
                throw new Exception(String.format("Already has association=%s with same peer address=%s and port=%d",
                        associationTemp.getName(), peerAddress, peerPort));
            }
        }

        if (server.getIpChannelType() != ipChannelType)
            throw new Exception(String.format("Server and Accociation has different IP channel type"));

        NettyAssociationImpl association = new NettyAssociationImpl(peerAddress, peerPort, serverName, assocName,
                ipChannelType);
        association.setManagement(this);

        NettyAssociationMap<String, Association> newAssociations = new NettyAssociationMap<String, Association>();
        newAssociations.putAll(this.associations);
        newAssociations.put(assocName, association);
        this.associations = newAssociations;
        // this.associations.put(assocName, association);

        FastList<String> newAssociations2 = new FastList<String>();
        newAssociations2.addAll(((NettyServerImpl) server).associations);
        newAssociations2.add(assocName);
        ((NettyServerImpl) server).associations = newAssociations2;
        // ((ServerImpl) server).associations.add(assocName);

        this.store();

        for (ManagementEventListener lstr : managementEventListeners) {
            try {
                lstr.onAssociationAdded(association);
            } catch (Throwable ee) {
                logger.error("Exception while invoking onAssociationAdded", ee);
            }
        }

        if (logger.isInfoEnabled()) {
            logger.info(String.format("Added Associoation=%s of type=%s", association.getName(),
                    association.getAssociationType()));
        }

        return association;
    }
}
 
Example 12
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Server addServer(String serverName, String hostAddress, int port, IpChannelType ipChannelType,
        boolean acceptAnonymousConnections, int maxConcurrentConnectionsCount, String[] extraHostAddresses)
        throws Exception {
    if (!this.started) {
        throw new Exception(String.format("Management=%s not started", this.name));
    }

    if (serverName == null) {
        throw new Exception("Server name cannot be null");
    }

    if (hostAddress == null) {
        throw new Exception("Server host address cannot be null");
    }

    if (port < 1) {
        throw new Exception("Server host port cannot be less than 1");
    }

    synchronized (this) {
        for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
            Server serverTemp = n.getValue();
            if (serverName.equals(serverTemp.getName())) {
                throw new Exception(String.format("Server name=%s already exist", serverName));
            }

            if (hostAddress.equals(serverTemp.getHostAddress()) && port == serverTemp.getHostport()) {
                throw new Exception(String.format("Server name=%s is already bound to %s:%d", serverTemp.getName(),
                        serverTemp.getHostAddress(), serverTemp.getHostport()));
            }
        }

        NettyServerImpl server = new NettyServerImpl(serverName, hostAddress, port, ipChannelType,
                acceptAnonymousConnections, maxConcurrentConnectionsCount, extraHostAddresses);
        server.setManagement(this);

        FastList<Server> newServers = new FastList<Server>();
        newServers.addAll(this.servers);
        newServers.add(server);
        this.servers = newServers;
        // this.servers.add(server);

        this.store();

        for (ManagementEventListener lstr : managementEventListeners) {
            try {
                lstr.onServerAdded(server);
            } catch (Throwable ee) {
                logger.error("Exception while invoking onServerAdded", ee);
            }
        }

        if (logger.isInfoEnabled()) {
            logger.info(String.format("Created Server=%s", server.getName()));
        }

        return server;
    }
}
 
Example 13
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void removeAssociation(String assocName) throws Exception {
    if (!this.started) {
        throw new Exception(String.format("Management=%s not started", this.name));
    }

    if (assocName == null) {
        throw new Exception("Association name cannot be null");
    }

    synchronized (this) {
        Association association = this.associations.get(assocName);

        if (association == null) {
            throw new Exception(String.format("No Association found for name=%s", assocName));
        }

        if (association.isStarted()) {
            throw new Exception(String.format("Association name=%s is started. Stop before removing", assocName));
        }

        NettyAssociationMap<String, Association> newAssociations = new NettyAssociationMap<String, Association>();
        newAssociations.putAll(this.associations);
        newAssociations.remove(assocName);
        this.associations = newAssociations;
        // this.associations.remove(assocName);

        if (((NettyAssociationImpl) association).getAssociationType() == AssociationType.SERVER) {
            for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
                Server serverTemp = n.getValue();
                if (serverTemp.getName().equals(association.getServerName())) {
                    FastList<String> newAssociations2 = new FastList<String>();
                    newAssociations2.addAll(((NettyServerImpl) serverTemp).associations);
                    newAssociations2.remove(assocName);
                    ((NettyServerImpl) serverTemp).associations = newAssociations2;
                    break;
                }
            }
        }

        this.store();

        for (ManagementEventListener lstr : managementEventListeners) {
            try {
                lstr.onAssociationRemoved(association);
            } catch (Throwable ee) {
                logger.error("Exception while invoking onAssociationRemoved", ee);
            }
        }
    }

}
 
Example 14
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
public void removeAssociation(String assocName) throws Exception {
	if (!this.started) {
		throw new Exception(String.format("Management=%s not started", this.name));
	}

	if (assocName == null) {
		throw new Exception("Association name cannot be null");
	}

	synchronized (this) {
		Association association = this.associations.get(assocName);

		if (association == null) {
			throw new Exception(String.format("No Association found for name=%s", assocName));
		}

		if (association.isStarted()) {
			throw new Exception(String.format("Association name=%s is started. Stop before removing", assocName));
		}

		AssociationMap<String, Association> newAssociations = new AssociationMap<String, Association>();
		newAssociations.putAll(this.associations);
		newAssociations.remove(assocName);
		this.associations = newAssociations;
		// this.associations.remove(assocName);

		if (((AssociationImpl) association).getAssociationType() == AssociationType.SERVER) {
			for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
				Server serverTemp = n.getValue();
				if (serverTemp.getName().equals(association.getServerName())) {
					FastList<String> newAssociations2 = new FastList<String>();
					newAssociations2.addAll(((ServerImpl) serverTemp).associations);
					newAssociations2.remove(assocName);
					((ServerImpl) serverTemp).associations = newAssociations2;
					// ((ServerImpl)
					// serverTemp).associations.remove(assocName);

					break;
				}
			}
		}

		this.store();

		for (ManagementEventListener lstr : managementEventListeners) {
			try {
				lstr.onAssociationRemoved(association);
			} catch (Throwable ee) {
				logger.error("Exception while invoking onAssociationRemoved", ee);
			}
		}
	}
}
 
Example 15
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
public AssociationImpl addServerAssociation(String peerAddress, int peerPort, String serverName, String assocName, IpChannelType ipChannelType)
		throws Exception {

	if (!this.started) {
		throw new Exception(String.format("Management=%s not started", this.name));
	}

	if (peerAddress == null) {
		throw new Exception("Peer address cannot be null");
	}

	if (peerPort < 1) {
		throw new Exception("Peer port cannot be less than 1");
	}

	if (serverName == null) {
		throw new Exception("Server name cannot be null");
	}

	if (assocName == null) {
		throw new Exception("Association name cannot be null");
	}

	synchronized (this) {
		if (this.associations.get(assocName) != null) {
			throw new Exception(String.format("Already has association=%s", assocName));
		}

		Server server = null;

		for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
			Server serverTemp = n.getValue();
			if (serverTemp.getName().equals(serverName)) {
				server = serverTemp;
			}
		}

		if (server == null) {
			throw new Exception(String.format("No Server found for name=%s", serverName));
		}

		for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n.getNext()) != end;) {
			Association associationTemp = n.getValue();

			if (peerAddress.equals(associationTemp.getPeerAddress()) && associationTemp.getPeerPort() == peerPort) {
				throw new Exception(String.format("Already has association=%s with same peer address=%s and port=%d", associationTemp.getName(),
						peerAddress, peerPort));
			}
		}

		if (server.getIpChannelType() != ipChannelType)
			throw new Exception(String.format("Server and Accociation has different IP channel type"));

		AssociationImpl association = new AssociationImpl(peerAddress, peerPort, serverName, assocName, ipChannelType);
		association.setManagement(this);

		AssociationMap<String, Association> newAssociations = new AssociationMap<String, Association>();
		newAssociations.putAll(this.associations);
		newAssociations.put(assocName, association);
		this.associations = newAssociations;
		// this.associations.put(assocName, association);

		FastList<String> newAssociations2 = new FastList<String>();
		newAssociations2.addAll(((ServerImpl) server).associations);
		newAssociations2.add(assocName);
		((ServerImpl) server).associations = newAssociations2;
		// ((ServerImpl) server).associations.add(assocName);

		this.store();

		for (ManagementEventListener lstr : managementEventListeners) {
			try {
				lstr.onAssociationAdded(association);
			} catch (Throwable ee) {
				logger.error("Exception while invoking onAssociationAdded", ee);
			}
		}

		if (logger.isInfoEnabled()) {
			logger.info(String.format("Added Associoation=%s of type=%s", association.getName(), association.getAssociationType()));
		}

		return association;
	}
}
 
Example 16
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 4 votes vote down vote up
public ServerImpl addServer(String serverName, String hostAddress, int port, IpChannelType ipChannelType, boolean acceptAnonymousConnections,
		int maxConcurrentConnectionsCount, String[] extraHostAddresses) throws Exception {

	if (!this.started) {
		throw new Exception(String.format("Management=%s not started", this.name));
	}

	if (serverName == null) {
		throw new Exception("Server name cannot be null");
	}

	if (hostAddress == null) {
		throw new Exception("Server host address cannot be null");
	}

	if (port < 1) {
		throw new Exception("Server host port cannot be less than 1");
	}

	synchronized (this) {
		for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
			Server serverTemp = n.getValue();
			if (serverName.equals(serverTemp.getName())) {
				throw new Exception(String.format("Server name=%s already exist", serverName));
			}

			if (hostAddress.equals(serverTemp.getHostAddress()) && port == serverTemp.getHostport()) {
				throw new Exception(String.format("Server name=%s is already bound to %s:%d", serverTemp.getName(), serverTemp.getHostAddress(),
						serverTemp.getHostport()));
			}
		}

		ServerImpl server = new ServerImpl(serverName, hostAddress, port, ipChannelType, acceptAnonymousConnections, maxConcurrentConnectionsCount,
				extraHostAddresses);
		server.setManagement(this);

		FastList<Server> newServers = new FastList<Server>();
		newServers.addAll(this.servers);
		newServers.add(server);
		this.servers = newServers;
		// this.servers.add(server);

		this.store();

		for (ManagementEventListener lstr : managementEventListeners) {
			try {
				lstr.onServerAdded(server);
			} catch (Throwable ee) {
				logger.error("Exception while invoking onServerAdded", ee);
			}
		}

		if (logger.isInfoEnabled()) {
			logger.info(String.format("Created Server=%s", server.getName()));
		}

		return server;
	}
}
 
Example 17
Source File: ItemStorage.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public FastList<Item> getItems() {
	FastList<Item> temp = FastList.newInstance();
	temp.addAll(items.values());
	return temp;
}
 
Example 18
Source File: LegionContainer.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public FastList<Legion> getAllLegions() {
	FastList<Legion> list = new FastList<Legion>();
	list.addAll(legionsByName.values());
	return list;
}
 
Example 19
Source File: GameSessionTable.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public List<TCPSession> getSessions()
{
	FastList<TCPSession> sessions = new FastList<TCPSession>();
	sessions.addAll(_gameSessionTable.values());
	return sessions;
}
 
Example 20
Source File: AbstractSwitchPart.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public List<SwitchCaseBlock> getCases()
{
    FastList<SwitchCaseBlock> cases = new FastList<SwitchCaseBlock>();
    cases.addAll(casesMap.values());
    return cases;
}