Search in sources :

Example 26 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class ProxyManager method resubscribe.

protected void resubscribe(ProxyServerConnection conn) {
    synchronized (proxyPool) {
        for (ItemPath key : proxyPool.keySet()) {
            ProxyMessage sub = new ProxyMessage(key, ProxyMessage.ADDPATH, false);
            Logger.msg(5, "ProxyManager.resubscribe() - item:" + key);
            conn.sendMessage(sub);
        }
    }
}
Also used : ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 27 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class Bootstrap method createServerItem.

public static void createServerItem() throws Exception {
    LookupManager lookupManager = Gateway.getLookupManager();
    String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
    thisServerPath = new DomainPath("/servers/" + serverName);
    ItemPath serverItem;
    try {
        serverItem = thisServerPath.getItemPath();
    } catch (ObjectNotFoundException ex) {
        Logger.msg("Creating server item " + thisServerPath);
        serverItem = new ItemPath();
        Gateway.getCorbaServer().createItem(serverItem);
        lookupManager.add(serverItem);
        thisServerPath.setItemPath(serverItem);
        lookupManager.add(thisServerPath);
    }
    int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
    Gateway.getStorage().put(serverItem, new Property(NAME, serverName, false), null);
    Gateway.getStorage().put(serverItem, new Property(TYPE, "Server", false), null);
    Gateway.getStorage().put(serverItem, new Property(KERNEL_VERSION, Gateway.getKernelVersion(), true), null);
    Gateway.getStorage().put(serverItem, new Property("ProxyPort", String.valueOf(proxyPort), false), null);
    Gateway.getStorage().put(serverItem, new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
    Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Property(org.cristalise.kernel.property.Property) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 28 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class Bootstrap method checkAgent.

/**
 * Checks for the existence of a agents so it can be used
 *
 * @param name
 * @param pass
 * @param rolePath
 * @param uuid
 * @return the Proxy representing the Agent
 * @throws Exception
 */
private static AgentProxy checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
    Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '" + name + "' agent.");
    LookupManager lookup = Gateway.getLookupManager();
    try {
        AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name));
        systemAgents.put(name, agentProxy);
        Logger.msg(3, "Bootstrap.checkAgent() - Agent '" + name + "' found.");
        return agentProxy;
    } catch (ObjectNotFoundException ex) {
    }
    Logger.msg("Bootstrap.checkAgent() - Agent '" + name + "' not found. Creating.");
    try {
        AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
        Gateway.getCorbaServer().createAgent(agentPath);
        lookup.add(agentPath);
        if (StringUtils.isNotBlank(pass))
            lookup.setAgentPassword(agentPath, pass);
        // assign admin role
        Logger.msg("Bootstrap.checkAgent() - Assigning role '" + rolePath.getName() + "'");
        Gateway.getLookupManager().addRole(agentPath, rolePath);
        Gateway.getStorage().put(agentPath, new Property(NAME, name, true), null);
        Gateway.getStorage().put(agentPath, new Property(TYPE, "Agent", false), null);
        AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(agentPath);
        // TODO: properly init agent here with wf, props and colls
        // agentProxy.initialise(agentId, itemProps, workflow, colls);
        systemAgents.put(name, agentProxy);
        return agentProxy;
    } catch (Exception ex) {
        Logger.error("Unable to create '" + name + "' Agent.");
        throw ex;
    }
}
Also used : AgentPath(org.cristalise.kernel.lookup.AgentPath) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) AgentProxy(org.cristalise.kernel.entity.proxy.AgentProxy) Property(org.cristalise.kernel.property.Property) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 29 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class BulkImport method importItemPath.

public ItemPath importItemPath(ItemPath item, Object locker) throws PersistencyException {
    try {
        ItemPath itemPath = (ItemPath) importCluster.get(item, PATH + "/Item");
        Gateway.getLookupManager().add(itemPath);
        return itemPath;
    } catch (ObjectCannotBeUpdated | ObjectAlreadyExistsException | CannotManageException e) {
        Logger.error(e);
        throw new PersistencyException(e.getMessage());
    }
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) ObjectCannotBeUpdated(org.cristalise.kernel.common.ObjectCannotBeUpdated) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 30 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class ClusterStorageManager method dumpCacheContents.

public void dumpCacheContents(int logLevel) {
    if (!Logger.doLog(logLevel))
        return;
    synchronized (memoryCache) {
        for (ItemPath itemPath : memoryCache.keySet()) {
            Logger.msg(logLevel, "Cached Objects of Item " + itemPath);
            Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
            try {
                synchronized (sysKeyMemCache) {
                    for (Object name : sysKeyMemCache.keySet()) {
                        String path = (String) name;
                        try {
                            Logger.msg(logLevel, "    Path " + path + ": " + sysKeyMemCache.get(path).getClass().getName());
                        } catch (NullPointerException e) {
                            Logger.msg(logLevel, "    Path " + path + ": reaped");
                        }
                    }
                }
            } catch (ConcurrentModificationException ex) {
                Logger.msg(logLevel, "Cache modified - aborting");
            }
        }
        Logger.msg(logLevel, "Total number of cached entities: " + memoryCache.size());
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

ItemPath (org.cristalise.kernel.lookup.ItemPath)36 DomainPath (org.cristalise.kernel.lookup.DomainPath)16 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)14 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)10 PersistencyException (org.cristalise.kernel.common.PersistencyException)10 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)10 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)6 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)5 CannotManageException (org.cristalise.kernel.common.CannotManageException)4 AgentPath (org.cristalise.kernel.lookup.AgentPath)4 Test (org.junit.Test)4 Aggregation (org.cristalise.kernel.collection.Aggregation)3 TraceableEntity (org.cristalise.kernel.entity.TraceableEntity)3 Path (org.cristalise.kernel.lookup.Path)3 Property (org.cristalise.kernel.property.Property)3 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)3 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 StringTokenizer (java.util.StringTokenizer)2 Dependency (org.cristalise.kernel.collection.Dependency)2