Search in sources :

Example 1 with ModTime

use of com.sun.enterprise.util.cluster.SyncRequest.ModTime in project Payara by payara.

the class ServerSynchronizer method synchronizeApplications.

/**
 * Synchronize all the applications in the applications directory.
 * We use the mod time of the application directory to decide if
 * the application has changed.  If it has changed, we also send
 * any of the generated content.
 */
private void synchronizeApplications(Payload.Outbound payload, Server server, SyncRequest sr) throws URISyntaxException {
    if (logger.isLoggable(Level.FINER))
        logger.finer("ServerSynchronizer: " + "synchronize application instance " + sr.instance);
    Map<String, Application> apps = getApps(server);
    File appsDir = env.getApplicationRepositoryPath();
    for (ModTime mt : sr.files) {
        if (apps.containsKey(mt.name)) {
            syncApp(apps.get(mt.name), appsDir, mt, payload);
            // if client has app, remove it from set
            apps.remove(mt.name);
        } else
            removeApp(apps.get(mt.name), appsDir, mt, payload);
    }
    // now do all the remaining apps the client doesn't have
    for (Map.Entry<String, Application> e : apps.entrySet()) syncApp(e.getValue(), appsDir, new ModTime(e.getKey(), 0), payload);
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application) ModTime(com.sun.enterprise.util.cluster.SyncRequest.ModTime)

Example 2 with ModTime

use of com.sun.enterprise.util.cluster.SyncRequest.ModTime in project Payara by payara.

the class ServerSynchronizer method synchronizeDirectory.

private void synchronizeDirectory(Payload.Outbound payload, Server server, SyncRequest sr, File dir, List<String> fileSet) throws URISyntaxException {
    for (ModTime mt : sr.files) {
        if (fileSet.contains(mt.name)) {
            // if client has file, remove it from set
            fileSet.remove(mt.name);
            syncFile(domainRootUri, dir, mt, payload);
        } else
            removeFile(domainRootUri, dir, mt, payload);
    }
    // now do all the remaining files the client doesn't have
    for (String name : fileSet) syncFile(domainRootUri, dir, new ModTime(name, 0), payload);
}
Also used : ModTime(com.sun.enterprise.util.cluster.SyncRequest.ModTime)

Example 3 with ModTime

use of com.sun.enterprise.util.cluster.SyncRequest.ModTime in project Payara by payara.

the class ServerSynchronizer method synchronizeConfig.

/**
 * Synchronize files in the config directory.
 * If the domain.xml file is up to date, don't worry
 * about any of the other files.
 */
private void synchronizeConfig(Payload.Outbound payload, Server server, SyncRequest sr) throws URISyntaxException {
    logger.finer("ServerSynchronizer: synchronize config");
    // find the domain.xml entry
    ModTime domainXmlMT = null;
    for (ModTime mt : sr.files) {
        if (mt.name.equals("domain.xml")) {
            domainXmlMT = mt;
            break;
        }
    }
    if (// couldn't find it, fake it
    domainXmlMT == null)
        domainXmlMT = new ModTime("domain.xml", 0);
    File configDir = env.getConfigDirPath();
    if (!syncFile(domainRootUri, configDir, domainXmlMT, payload)) {
        logger.fine("ServerSynchronizer: domain.xml HAS NOT CHANGED, " + "thus no files will be synchronized");
        return;
    }
    // get the set of all the config files we need to consider
    Set<String> configFileSet = getConfigFileNames();
    // already handled it
    configFileSet.remove("domain.xml");
    // add the list of file realm files
    getRealmFileNames(server, configFileSet);
    for (ModTime mt : sr.files) {
        if (// did domain.xml above
        mt.name.equals("domain.xml"))
            continue;
        if (configFileSet.contains(mt.name)) {
            // if client has file, remove it from set
            configFileSet.remove(mt.name);
            syncFile(domainRootUri, configDir, mt, payload);
        } else
            removeFile(domainRootUri, configDir, mt, payload);
    }
    // now do all the remaining files the client doesn't have
    for (String name : configFileSet) syncFile(domainRootUri, configDir, new ModTime(name, 0), payload);
}
Also used : ModTime(com.sun.enterprise.util.cluster.SyncRequest.ModTime)

Aggregations

ModTime (com.sun.enterprise.util.cluster.SyncRequest.ModTime)3 Application (com.sun.enterprise.config.serverbeans.Application)1