Example usage for java.lang String clone

List of usage examples for java.lang String clone

Introduction

In this page you can find the example usage for java.lang String clone.

Prototype

@HotSpotIntrinsicCandidate
protected native Object clone() throws CloneNotSupportedException;

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:org.apache.hadoop.distributedloadsimulator.sls.SLSRunner.java

public SLSRunner(String inputTraces[], String nodeFile, String outputDir, Set<String> trackedApps,
        boolean printsimulation, boolean yarnNodeDeployment, boolean distributedMode, boolean loadSimMode,
        String resourceTrackerAddress, String resourceManagerAddress, String rmiAddress, int rmiPort,
        boolean isLeader, long simulationDuration) throws IOException, ClassNotFoundException {
    this.rm = null;
    this.isLeader = isLeader;
    this.simulationDuration = simulationDuration;
    this.yarnNode = yarnNodeDeployment;
    distributedmode = distributedMode;//  w  w w  .  j  av  a  2s  . c om
    this.loadsimulatormode = loadSimMode;
    if (resourceTrackerAddress.split(",").length == 1) { // so we only have one RT
        this.numberOfRT = 1;
    } else {
        for (int i = 0; i < resourceTrackerAddress.split(",").length; ++i) {
        }
        this.numberOfRT = resourceTrackerAddress.split(",").length;
    }
    this.inputTraces = inputTraces.clone();
    this.nodeFile = nodeFile;
    this.trackedApps = trackedApps;
    this.printSimulation = printsimulation;
    metricsOutputDir = outputDir;
    this.listOfRMIIpAddress = rmiAddress.split(",");
    this.rmiPort = rmiPort;

    nmMap = new HashMap<NodeId, NMSimulator>();
    queueAppNumMap = new HashMap<String, Integer>();
    amMap = new HashMap<String, AMSimulator>();
    amClassMap = new HashMap<String, Class>();

    // runner configuration
    conf = new Configuration();
    YarnAPIStorageFactory.setConfiguration(conf);
    RMStorageFactory.setConfiguration(conf);
    conf.addResource("sls-runner.xml");
    // runner
    int poolSize = conf.getInt(SLSConfiguration.NM_RUNNER_POOL_SIZE,
            SLSConfiguration.NM_RUNNER_POOL_SIZE_DEFAULT);
    SLSRunner.nodeRunner.setQueueSize(poolSize);
    SLSRunner.applicationRunner.setQueueSize(poolSize);
    // <AMType, Class> map
    for (Map.Entry e : conf) {
        String key = e.getKey().toString();
        if (key.startsWith(SLSConfiguration.AM_TYPE)) {
            String amType = key.substring(SLSConfiguration.AM_TYPE.length());
            amClassMap.put(amType, Class.forName(conf.get(key)));
        }
    }

    containerMemoryMB = conf.getInt(SLSConfiguration.CONTAINER_MEMORY_MB,
            SLSConfiguration.CONTAINER_MEMORY_MB_DEFAULT);
}

From source file:org.simplx.args.MainArgs.java

/**
 * Creates a new {@link MainArgs} object that will return specified options,
 * arguments, and operands. The {@code prog} parameter is the program name.
 *
 * @param programName The name to use for the program.
 * @param args        The command line arguments.
 *//*  w  w  w  .ja  v a  2s  .c  o m*/
public MainArgs(String programName, String... args) {
    if (logger.isLoggable(Level.FINE)) {
        SimplxLogging.logFormat(logger, Level.FINE, "MainArgs(%s)", programName);
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            SimplxLogging.logFormat(logger, Level.FINE, "    %d: %s", i, arg);
        }
    }

    this.programName = programName;
    this.args = args.clone();
    used = new BitSet(args.length);
    options = new ArrayList<Opt>();
    curGroup = 0;
    groups = new ArrayList<String>();
    groups.add("");
}

From source file:sos.scheduler.editor.app.MainWindow.java

public static void shellActivated_() {
    try {/*from   ww w.j a  va 2 s .c o  m*/
        if (!(MainWindow.container.getCurrentEditor() instanceof SchedulerForm)
                || MainWindow.getContainer().getCurrentEditor() == null || !flag) {
            return;
        }
        DomParser dom = getSpecifiedDom();
        if (dom.getFilename() != null) {
            File f = new File(dom.getFilename());
            ArrayList<File> changeFiles = new ArrayList<File>();// gilt fr Hot Folder Dateien, die von einer anderen Process verndert
            // wurden
            ArrayList<File> newFFiles = new ArrayList<File>();
            ArrayList<File> delFFiles = new ArrayList<File>();
            HashMap<String, Long> hFFiles = new HashMap<String, Long>();
            // System.out.println("file     = " + dom.getLastModifiedFile());
            // System.out.println("dom file = " + f.lastModified() );
            // Hot Folder. Hat sich ein Holt Folder Datei ausserhalb verndert?
            long lastmod = 0;
            if (dom.getFilename() != null) {
                hFFiles = ((SchedulerDom) dom).getHotFolderFiles();
                if (f.isDirectory()) {
                    ArrayList<File> listOfhotFolderFiles = ((SchedulerDom) dom)
                            .getHoltFolderFiles(new File(dom.getFilename()));
                    // wurden Venderungen ausserhalb durchgefhrt
                    for (int i = 0; i < listOfhotFolderFiles.size(); i++) {
                        File fFile = listOfhotFolderFiles.get(i);
                        try {
                            long current = fFile.lastModified();// aktuelle nderungs Zeitstempel
                            if (hFFiles.containsKey(fFile.getName())) {
                                long domc = Long.parseLong((hFFiles.get(fFile.getName()).toString()));// gespeicherte Zeitstempel
                                if (current != domc)
                                    changeFiles.add(fFile);
                            } else {
                                // sind neue HotFolder Dateien ausserhalb zustande gekommen?
                                // ("jobname" + "_" + name, what)
                                String fName = fFile.getName();
                                int pos1 = fName.indexOf(".");
                                int pos2 = fName.lastIndexOf(".");
                                String n = fName.substring(pos1, pos2) + "_" + fName.substring(0, pos1);
                                if (!(((SchedulerDom) dom).getChangedJob().get(n) != null
                                        && ((SchedulerDom) dom).getChangedJob().get(n)
                                                .equals(SchedulerDom.DELETE)))
                                    newFFiles.add(fFile);
                            }
                        } catch (Exception e) {
                            // tu nichts
                            e.printStackTrace();
                        }
                        lastmod = lastmod + fFile.lastModified();
                    }
                    // berprfen, ob Dateien ausserhalb gelscht wurden
                    Iterator<String> it = hFFiles.keySet().iterator();
                    while (it.hasNext()) {
                        String fName = it.next();
                        if (!new File(dom.getFilename(), fName).exists()) {
                            delFFiles.add(new File(dom.getFilename(), fName));
                        }
                    }
                } else {
                    // if(!new File(dom.getFilename()).exists())
                    // delFFiles.add(new File(dom.getFilename()));
                    lastmod = f.lastModified();
                }
            }
            if (dom.getFilename() != null && lastmod != dom.getLastModifiedFile()) {
                flag = false;
                String msg = EMPTY;
                if (f.isDirectory()) {
                    msg = Messages.getString("directory.modified", dom.getFilename());
                    if (newFFiles.size() > 0) {
                        msg = msg + "\n" + Messages.getString("files.new"); // "New Files:";
                        for (int i = 0; i < newFFiles.size(); i++) {
                            if (i == 0)
                                msg = msg + conNewlineTab + newFFiles.get(i).getName();
                            else
                                msg = msg + conNewlineTab + newFFiles.get(i).getName();
                        }
                    }
                    if (changeFiles.size() > 0) {
                        msg = msg + "\n" + Messages.getString("files.changed"); // "Changed Files:";
                        for (int i = 0; i < changeFiles.size(); i++) {
                            if (i == 0)
                                msg = msg + conNewlineTab + changeFiles.get(i);
                            else
                                msg = msg + conNewlineTab + changeFiles.get(i);
                        }
                    }
                    if (delFFiles.size() > 0) {
                        msg = msg + "\n" + Messages.getString("files.removed"); // "Removed Files:";
                        for (int i = 0; i < delFFiles.size(); i++) {
                            if (i == 0)
                                msg = msg + conNewlineTab + delFFiles.get(i);
                            else
                                msg = msg + conNewlineTab + delFFiles.get(i);
                        }
                    }
                    msg = msg + "\n" + Messages.getString("reload.wanted");
                } else {
                    if (!new File(dom.getFilename()).exists()) {
                        msg = Messages.getString("file.deleted.on.filesystem", dom.getFilename());
                        delFFiles.add(new File(dom.getFilename()));
                    } else {
                        msg = Messages.getString("file.changed.on.filesystem", dom.getFilename());
                    }
                }
                int c = MainWindow.message(sShell, msg, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                if (c == SWT.YES) {
                    try {
                        if (f.isDirectory()) {
                            for (int i = 0; i < changeFiles.size(); i++) {
                                File hFfile = changeFiles.get(i);
                                String sXPATH = getXPathString(hFfile, false);
                                XPath x1 = XPath.newInstance(sXPATH);
                                List<Element> listOfElement = x1.selectNodes(dom.getDoc());
                                if (!listOfElement.isEmpty()) {
                                    Element e = listOfElement.get(0);
                                    Element pe = e.getParentElement();
                                    e.detach();
                                    Element n = MergeAllXMLinDirectory.readElementFromHotHolderFile(hFfile);
                                    pe.addContent((Element) n.clone());
                                }
                            }
                            // Es wurden ausserhalb vom Editor neue Hot Folder dateien hinzugefgt. In diesem Fall soll der Editor
                            // aktualisiert werden
                            for (int i = 0; i < newFFiles.size(); i++) {
                                File newHFFile = newFFiles.get(i);
                                String sXPATH = getXPathString(newHFFile, true);
                                XPath x1 = XPath.newInstance(sXPATH);
                                List<Element> listOfElement = x1.selectNodes(dom.getDoc());
                                if (!listOfElement.isEmpty()) {
                                    Element pe = listOfElement.get(0);
                                    Element n = MergeAllXMLinDirectory.readElementFromHotHolderFile(newHFFile);
                                    pe.addContent((Element) n.clone());
                                } else {
                                    Element pe = new Element(sXPATH);
                                    dom.getRoot().addContent(pe);
                                    Element n = MergeAllXMLinDirectory.readElementFromHotHolderFile(newHFFile);
                                    pe.addContent((Element) n.clone());
                                }
                            }
                            for (int i = 0; i < delFFiles.size(); i++) {
                                File delFile = delFFiles.get(i);
                                String sXPATH = getXPathString(delFile, false);
                                XPath x1 = XPath.newInstance(sXPATH);
                                List<Element> listOfElement = x1.selectNodes(dom.getDoc());
                                if (!listOfElement.isEmpty()) {
                                    Element pe = listOfElement.get(0);
                                    pe.detach();
                                    ((SchedulerDom) dom).getHotFolderFiles().remove(delFile.getName());
                                }
                            }
                            if (changeFiles.size() > 0 || newFFiles.size() > 0 || delFFiles.size() > 0) {
                                SchedulerForm form = (SchedulerForm) container.getCurrentEditor();
                                form.updateTree("main");
                                // form.updateCommands();
                                form.update();
                                dom.readFileLastModified();
                            }
                        } else {
                            if (delFFiles.size() > 0) {
                                // current Tabraiter soll geschlossen werden weil die Kpnfigurationsdatei ausserhalb gelscht wurden
                                MainWindow.getContainer().getCurrentTab().dispose();
                                return;
                            }
                            dom.read(dom.getFilename());
                            if (container.getCurrentEditor() instanceof SchedulerForm) {
                                SchedulerForm form = (SchedulerForm) container.getCurrentEditor();
                                form.updateTree("main");
                                form.update();
                            } else if (container.getCurrentEditor() instanceof DocumentationForm) {
                                DocumentationForm form = (DocumentationForm) container.getCurrentEditor();
                                form.updateTree("main");
                                form.update();
                            } else if (container.getCurrentEditor() instanceof ActionsForm) {
                                ActionsForm form = (ActionsForm) container.getCurrentEditor();
                                form.updateTree("main");
                                form.update();
                            }
                            // dom.setFileLastModified(f.lastModified());
                            // System.out.println("neu= " + f.lastModified());
                            // System.out.println("neu= " + dom.getFileLastModified());
                        }
                    } catch (Exception e) {
                        System.out.println(e.toString());
                    }
                } else {
                    if (!f.isDirectory()) {
                        if (delFFiles.size() > 0) {
                            dom.setFilename(null);
                            dom.setChanged(true);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        try {
            new ErrorLog(Messages.getString("exception.raised", sos.util.SOSClassUtil.getMethodName()), e);
        } catch (Exception ee) {
            // tu nichts
        }
    }
    flag = true;
}