Example usage for java.util LinkedList clear

List of usage examples for java.util LinkedList clear

Introduction

In this page you can find the example usage for java.util LinkedList clear.

Prototype

public void clear() 

Source Link

Document

Removes all of the elements from this list.

Usage

From source file:com.commander4j.thread.OutboundMessageThread.java

public void run() {
    logger.debug("OutboundMessageThread running");
    setSessionID(JUnique.getUniqueID());
    JDBUser user = new JDBUser(getHostID(), getSessionID());
    user.setUserId("interface");
    user.setPassword("interface");
    user.setLoginPassword("interface");
    Common.userList.addUser(getSessionID(), user);
    Common.sd.setData(getSessionID(), "silentExceptions", "Yes", true);

    Boolean dbconnected = false;// w  ww  . j  a v a2  s . c  o  m

    if (Common.hostList.getHost(hostID).isConnected(sessionID) == false) {

        dbconnected = Common.hostList.getHost(hostID).connect(sessionID, hostID);

    } else {
        dbconnected = true;
    }

    if (dbconnected) {

        JeMail mail = new JeMail(getHostID(), getSessionID());
        JDBInterfaceRequest ir = new JDBInterfaceRequest(getHostID(), getSessionID());
        JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
        OutgoingProductionDeclarationConfirmation opdc = new OutgoingProductionDeclarationConfirmation(
                getHostID(), getSessionID());
        OutgoingDespatchConfirmation odc = new OutgoingDespatchConfirmation(getHostID(), getSessionID());
        OutgoingDespatchPreAdvice opa = new OutgoingDespatchPreAdvice(getHostID(), getSessionID());
        OutgoingDespatchEmail ode = new OutgoingDespatchEmail(getHostID(), getSessionID());
        OutgoingEquipmentTracking oet = new OutgoingEquipmentTracking(getHostID(), getSessionID());
        OutgoingPalletStatusChange psc = new OutgoingPalletStatusChange(getHostID(), getSessionID());
        OutgoingPalletSplit ops = new OutgoingPalletSplit(getHostID(), getSessionID());
        OutgoingPalletDelete opd = new OutgoingPalletDelete(getHostID(), getSessionID());
        LinkedList<Long> irqList = new LinkedList<Long>();
        int noOfMessages = 0;

        while (true) {

            JWait.milliSec(500);

            if (allDone) {
                if (dbconnected) {
                    Common.hostList.getHost(hostID).disconnect(getSessionID());
                }
                return;
            }

            irqList.clear();
            irqList = ir.getInterfaceRequestIDs();
            noOfMessages = irqList.size();

            if (noOfMessages > 0) {
                for (int x = 0; x < noOfMessages; x++) {
                    JWait.milliSec(100);
                    ir.setInterfaceRequestID(irqList.get(x));
                    ir.getInterfaceRequestProperties();

                    if (ir.getMode().equals("Inbound File Re-Submit")) {
                        if (inter.getInterfaceProperties(ir.getInterfaceType(), "Input") == true) {
                            String sourceFile = Common.base_dir + java.io.File.separator + "xml"
                                    + java.io.File.separator + "interface" + java.io.File.separator + "error"
                                    + java.io.File.separator + ir.getInterfaceType() + java.io.File.separator
                                    + ir.getFilename();

                            destinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename();
                            renamedDestinationFile = inter.getRealPath() + java.io.File.separator
                                    + ir.getFilename().replaceAll(".xml", ".lmx");

                            mover.move_File(sourceFile, renamedDestinationFile);
                            mover.move_File(renamedDestinationFile, destinationFile);
                            ir.delete();

                        }
                    }

                    if (ir.getMode().equals("Normal")) {

                        errorMessage = "Unknown Outbound Interface Type :" + ir.getInterfaceType();
                        messageProcessedOK = false;

                        if (ir.getInterfaceType().equals("Production Declaration")) {
                            messageProcessedOK = opdc.processMessage(ir.getTransactionRef());
                            errorMessage = opdc.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Production Declaration",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Pallet Status Change")) {
                            messageProcessedOK = psc.processMessage(ir.getTransactionRef());
                            errorMessage = psc.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Pallet Status Change",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Pallet Split")) {
                            messageProcessedOK = ops.processMessage(ir.getTransactionRef());
                            errorMessage = ops.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Pallet Split",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Pallet Delete")) {
                            messageProcessedOK = opd.processMessage(ir.getTransactionRef());
                            errorMessage = opd.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Pallet Delete",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Despatch Confirmation")) {
                            messageProcessedOK = odc.processMessage(ir.getTransactionRef());
                            errorMessage = odc.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Despatch Confirmation",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Despatch Pre Advice")) {
                            messageProcessedOK = opa.processMessage(ir.getTransactionRef());
                            errorMessage = opa.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Despatch Pre Advice",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Despatch Email")) {
                            messageProcessedOK = ode.processMessage(ir.getTransactionRef());
                            errorMessage = ode.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Despatch Email",
                                    messageProcessedOK.toString());
                        }

                        if (ir.getInterfaceType().equals("Equipment Tracking")) {
                            messageProcessedOK = oet.processMessage(ir.getTransactionRef());
                            errorMessage = oet.getErrorMessage();
                            GenericMessageHeader.updateStats("Output", "Equipment Tracking",
                                    messageProcessedOK.toString());
                        }

                        if (messageProcessedOK == true) {
                            ir.delete();
                        } else {
                            ir.update(irqList.get(x), "Error");
                            if (inter.getInterfaceProperties(ir.getInterfaceType(), "Output") == true) {
                                if (inter.getEmailError() == true) {
                                    String emailaddresses = inter.getEmailAddresses();

                                    StringConverter stringConverter = new StringConverter();
                                    ArrayConverter arrayConverter = new ArrayConverter(String[].class,
                                            stringConverter);
                                    arrayConverter.setDelimiter(';');
                                    arrayConverter.setAllowedChars(new char[] { '@' });

                                    String[] emailList = (String[]) arrayConverter.convert(String[].class,
                                            emailaddresses);

                                    if (emailList.length > 0) {
                                        try {
                                            String siteName = Common.hostList.getHost(getHostID())
                                                    .getSiteDescription();
                                            mail.postMail(emailList,
                                                    "Error Processing Outgoing " + ir.getInterfaceType()
                                                            + " for [" + siteName + "] on "
                                                            + JUtility.getClientName(),
                                                    errorMessage, "", "");
                                        } catch (MessagingException e) {

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

From source file:com.unboundid.scim2.common.utils.Parser.java

/**
 * Close a grouping of filters enclosed by parenthesis.
 *
 * @param operators The stack of operators tokens.
 * @param output The stack of output tokens.
 * @param isAtTheEnd Whether the end of the filter string was reached.
 * @return The last operator encountered that signaled the end of the group.
 * @throws BadRequestException If the filter string could not be parsed.
 *///from w  w w. j a v  a2s  .c o  m
private static String closeGrouping(final Stack<String> operators, final Stack<Filter> output,
        final boolean isAtTheEnd) throws BadRequestException {
    String operator = null;
    String repeatingOperator = null;
    LinkedList<Filter> components = new LinkedList<Filter>();

    // Iterate over the logical operators on the stack until either there are
    // no more operators or an opening parenthesis or not is found.
    while (!operators.isEmpty()) {
        operator = operators.pop();
        if (operator.equals("(") || operator.equalsIgnoreCase(FilterType.NOT.getStringValue())) {
            if (isAtTheEnd) {
                throw BadRequestException.invalidFilter("Unexpected end of filter string");
            }
            break;
        }
        if (repeatingOperator == null) {
            repeatingOperator = operator;
        }
        if (!operator.equals(repeatingOperator)) {
            if (output.isEmpty()) {
                throw BadRequestException.invalidFilter("Unexpected end of filter string");
            }
            components.addFirst(output.pop());
            if (repeatingOperator.equalsIgnoreCase(FilterType.AND.getStringValue())) {
                output.push(Filter.and(components));
            } else {
                output.push(Filter.or(components));
            }
            components.clear();
            repeatingOperator = operator;
        }
        if (output.isEmpty()) {
            throw BadRequestException.invalidFilter("Unexpected end of filter string");
        }
        components.addFirst(output.pop());
    }

    if (repeatingOperator != null && !components.isEmpty()) {
        if (output.isEmpty()) {
            throw BadRequestException.invalidFilter("Unexpected end of filter string");
        }
        components.addFirst(output.pop());
        if (repeatingOperator.equalsIgnoreCase(FilterType.AND.getStringValue())) {
            output.push(Filter.and(components));
        } else {
            output.push(Filter.or(components));
        }
    }

    return operator;
}

From source file:is.illuminati.block.spyros.garmin.model.Activity.java

/**
 * Get total altitude gained//ww w .  ja  v  a 2 s.  c o m
 * @return total altitude gain
 */
public Length getAltitudeGain() {
    final Length minimumGain = Length.createLengthInMeters(5.0);
    Length totalGain = Length.createLengthInMeters(0.0);

    // only count as climb if 5 meters are gained without a drop in between.
    // This is a crude way  to filter out any noise.
    LinkedList<TrackPoint> climbingStretch = Lists.newLinkedList();
    for (TrackPoint trackPoint : getTrackPoints()) {
        if (trackPoint.getAltitudeDelta().getValueInMeters() > 0.0) {
            climbingStretch.add(trackPoint);
        } else {
            Length gain = Length.createLengthInMeters(0.0);
            for (TrackPoint climbingTrackPoint : climbingStretch) {
                gain = gain.add(climbingTrackPoint.getAltitudeDelta());
            }
            if (gain.compareTo(minimumGain) > 0) {
                totalGain = totalGain.add(gain);
            }
            climbingStretch.clear();
        }
    }
    return totalGain;
}

From source file:gedi.util.io.text.LineOrientedFile.java

private void writeTmp(List<LineOrientedFile> tmps, LinkedList<String> lines, Comparator<String> comp,
        LineOrientedFile out) throws IOException {
    LineOrientedFile lof = new LineOrientedFile(out.getAbsolutePath() + ".tmp" + tmps.size());
    tmps.add(lof);/*  w ww.ja v a  2s .  c o  m*/
    Collections.sort(lines, comp);
    lof.startWriting();
    for (String s : lines)
        lof.writeLine(s);
    lof.finishWriting();
    lines.clear();
}

From source file:AppMain.java

@Override
public void handle(Request request, Response response) {

    long time = System.currentTimeMillis();
    System.out.print(request.getPath().toString() + "\t" + request.getValues("Host") + " ");
    System.out.println(request.getValues("User-agent") + " ");
    response.setDate("Date", time);
    try {// w  ww .  ja v  a  2  s .co  m

        //static? send the file
        if (request.getPath().toString().startsWith("/static/")) {
            String path = request.getPath().toString().substring("/static/".length());
            File requested = new File("static" + File.separatorChar + path.replace('/', File.separatorChar));
            if (!requested.getCanonicalPath().startsWith(new File("static").getCanonicalPath())) {
                System.err.println("Error, path outside the static folder:" + path);
                return;
            }
            if (!requested.isFile()) {
                System.err.println("Error, file not found:" + path);
                return;
            }
            //valid path, send it
            String mimet = URLConnection.guessContentTypeFromName(path);
            if (path.endsWith(".js"))
                mimet = "application/javascript";
            if (path.endsWith(".css"))
                mimet = "text/css";
            System.out.println("sending static resource:'" + path + "' mimetype:" + mimet);
            response.setDate("Date", requested.lastModified());
            try (PrintStream body = response.getPrintStream()) {
                response.setValue("Content-Type", mimet);
                FileInputStream fis = new FileInputStream(requested);
                //copy the stream
                IOUtils.copy(fis, body);
                fis.close();
            }
            return;
        }
        //main page, show the index
        if (request.getPath().toString().equals("/")) {
            try (PrintStream body = response.getPrintStream()) {
                response.setValue("Content-Type", "text/html;charset=utf-8");
                File file = new File("index.html");
                System.out.println(file.getAbsolutePath());
                byte[] data;
                try (FileInputStream fis = new FileInputStream(file)) {
                    data = new byte[(int) file.length()];
                    fis.read(data);
                }
                body.write(data);
            }
        }

        if (request.getPath().toString().startsWith("/parse")) {
            response.setValue("Content-Type", "application/json;charset=utf-8");
            try (PrintStream body = response.getPrintStream()) {
                String text = request.getQuery().get("text");
                String pattern = request.getQuery().get("pattern");
                if (text == null || pattern == null) {
                    body.write("{'error':'pattern or text not specified'}".getBytes("UTF-8"));
                    body.close();
                }
                System.err.println("request to parse text: " + text + "\nfor pattern: " + pattern);
                MatchingResults results = null;
                JSONObject ret = new JSONObject();
                try {
                    long start = System.currentTimeMillis();
                    results = fm.matches(text, pattern, FlexiMatcher.getDefaultAnnotator(), true, false, true);
                    ret.put("time to parse", System.currentTimeMillis() - start);
                } catch (RuntimeException r) {
                    body.write(("{\"error\":" + JSONObject.quote(r.getMessage()) + "}").getBytes("UTF-8"));
                    body.close();
                    return;
                }
                ret.put("matches", results.isMatching());
                ret.put("empty_match", results.isEmptyMatch());
                ret.put("text", text);
                ret.put("pattern", pattern);
                if (!results.getAnnotations().isPresent()) {
                    body.write(ret.toString().getBytes("UTF-8"));
                    body.close();
                    return;
                }
                for (LinkedList<TextAnnotation> interpretation : results.getAnnotations().get()) {
                    JSONObject addMe = new JSONObject();

                    for (TextAnnotation v : interpretation) {
                        addMe.append("annotations", new JSONObject(v.toJSON()));
                    }
                    ret.append("interpretations", addMe);
                }
                body.write(ret.toString(1).getBytes("UTF-8"));
            }
            return;
        }

        if (request.getPath().toString().startsWith("/trace")) {
            response.setValue("Content-Type", "application/json;charset=utf-8");
            try (PrintStream body = response.getPrintStream()) {
                String text = request.getQuery().get("text");
                String pattern = request.getQuery().get("pattern");
                if (text == null || pattern == null) {
                    body.write("{'error':'pattern or text not specified'}".getBytes("UTF-8"));
                    body.close();
                }
                System.err.println("request to parse text: " + text + "\nfor pattern: " + pattern);
                JSONObject ret = new JSONObject();
                ListingAnnotatorHandler ah;
                try {
                    long start = System.currentTimeMillis();
                    ah = new ListingAnnotatorHandler();
                    fm.matches(text, pattern, ah, true, false, true);
                    ret.put("time", System.currentTimeMillis() - start);
                } catch (RuntimeException r) {
                    body.write(("{\"error\":" + JSONObject.quote(r.getMessage()) + "}").getBytes("UTF-8"));
                    body.close();
                    return;
                }
                ret.put("text", text);
                ret.put("pattern", pattern);
                LinkedList<TextAnnotation> nonOverlappingTA = new LinkedList<>();
                JSONObject addMe = new JSONObject();
                for (TextAnnotation v : ah.getAnnotations()) {
                    if (nonOverlappingTA.stream().anyMatch(p -> p.getSpan().intersects(v.getSpan()))) {
                        ret.append("interpretations", addMe);
                        addMe = new JSONObject();
                        addMe.append("annotations", new JSONObject(v.toJSON()));
                        nonOverlappingTA.clear();
                    } else {
                        addMe.append("annotations", new JSONObject(v.toJSON()));
                    }
                    nonOverlappingTA.add(v);

                }
                ret.append("interpretations", addMe);
                body.write(ret.toString(1).getBytes("UTF-8"));
            }
            return;
        }

        if (request.getPath().toString().startsWith("/addtag")) {
            if (tagCount == 0)
                fwTag.write("\n#tags added from web interface at " + LocalDate.now().toString() + "\n");

            tagCount++;
            response.setValue("Content-Type", "application/json;charset=utf-8");
            try (PrintStream body = response.getPrintStream()) {
                String tag = request.getQuery().getOrDefault("tag", "");
                String pattern = request.getQuery().getOrDefault("pattern", "");

                if (tag.isEmpty() || pattern.isEmpty()) {
                    body.write("{\"error\":\"tag or pattern not specified\"}".getBytes("UTF-8"));
                    body.close();
                    return;
                }

                String identifier = request.getQuery().getOrDefault("identifier", "");
                String annotationTemplate = request.getQuery().getOrDefault("annotation_template", "").trim();

                if (identifier.isEmpty()) {
                    identifier = "auto_" + LocalDate.now().toString() + "_" + tagCount;
                }

                //check that rule identifiers are known
                for (String part : ExpressionParser.split(pattern)) {
                    if (!part.startsWith("["))
                        continue;
                    if (!fm.isBoundRule(ExpressionParser.ruleName(part))) {
                        body.write(("{\"error\":\"rule '" + ExpressionParser.ruleName(part) + "' non known\"}")
                                .getBytes("UTF-8"));
                        body.close();
                        return;
                    }
                }

                fwTag.write(tag + "\t" + pattern + "\t" + identifier + "\t" + annotationTemplate + "\n");
                fwTag.flush();
                if (annotationTemplate.isEmpty())
                    fm.addTagRule(tag, pattern, identifier);
                else
                    fm.addTagRule(tag, pattern, identifier, annotationTemplate);
                body.write(("{\"identifier\":" + JSONObject.quote(identifier) + "}").getBytes("UTF-8"));
            }
            return;

        }
        //unknown request
        try (PrintStream body = response.getPrintStream()) {
            response.setValue("Content-Type", "text/plain");
            response.setDate("Last-Modified", time);
            response.setCode(401);
            body.println("HTTP request for page '" + request.getPath().toString() + "' non understood in "
                    + this.getClass().getCanonicalName());
        }
    } catch (IOException | JSONException e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:com.commander4j.thread.AutoLabellerThread.java

public void run() {
    logger.debug("AutoLabeller Thread running");
    setSessionID(JUnique.getUniqueID());
    JDBUser user = new JDBUser(getHostID(), getSessionID());
    user.setUserId("interface");
    user.setPassword("interface");
    user.setLoginPassword("interface");
    Common.userList.addUser(getSessionID(), user);
    Common.sd.setData(getSessionID(), "silentExceptions", "Yes", true);

    Boolean dbconnected = false;/*from www .j  av  a  2 s  . co m*/

    if (Common.hostList.getHost(hostID).isConnected(sessionID) == false) {

        dbconnected = Common.hostList.getHost(hostID).connect(sessionID, hostID);

    } else {
        dbconnected = true;
    }

    if (dbconnected) {

        JDBViewAutoLabellerPrinter alp = new JDBViewAutoLabellerPrinter(getHostID(), getSessionID());
        LinkedList<JDBViewAutoLabellerPrinter> autolabellerList = new LinkedList<JDBViewAutoLabellerPrinter>();

        int noOfMessages = 0;

        while (true) {

            JWait.milliSec(500);

            if (allDone) {
                if (dbconnected) {
                    Common.hostList.getHost(hostID).disconnect(getSessionID());
                }
                return;
            }

            autolabellerList.clear();
            autolabellerList = alp.getModifiedPrinterLines();
            noOfMessages = autolabellerList.size();

            if (noOfMessages > 0) {
                for (int x = 0; x < noOfMessages; x++) {
                    JWait.milliSec(100);

                    JDBViewAutoLabellerPrinter autolabview = autolabellerList.get(x);

                    messageProcessedOK = true;
                    messageError = "";

                    if (autolabview.getPrinterObj().isEnabled()) {
                        logger.debug("Line             =" + autolabview.getAutoLabellerObj().getLine());
                        logger.debug("Line Description =" + autolabview.getAutoLabellerObj().getDescription());
                        logger.debug("Printer ID       =" + autolabview.getPrinterObj().getPrinterID());
                        logger.debug("Printer Enabled  =" + autolabview.getPrinterObj().isEnabled());
                        logger.debug("Export Path      =" + autolabview.getPrinterObj().getExportRealPath());
                        logger.debug("Export Enabled   =" + autolabview.getPrinterObj().isExportEnabled());
                        logger.debug("Export Format    =" + autolabview.getPrinterObj().getExportFormat());
                        logger.debug("Direct Print     =" + autolabview.getPrinterObj().isDirectPrintEnabled());
                        logger.debug("Printer Type     =" + autolabview.getPrinterObj().getPrinterType());
                        logger.debug("Printer IP       =" + autolabview.getPrinterObj().getIPAddress());
                        logger.debug("Printer Port     =" + autolabview.getPrinterObj().getPort());
                        logger.debug("Process Order    =" + autolabview.getLabelDataObj().getProcessOrder());
                        logger.debug("Material         =" + autolabview.getLabelDataObj().getMaterial());
                        logger.debug("Module ID        =" + autolabview.getModuleObj().getModuleId());
                        logger.debug("Module Type      =" + autolabview.getModuleObj().getType());

                        if (autolabview.getPrinterObj().isExportEnabled()) {
                            String exportPath = JUtility.replaceNullStringwithBlank(
                                    JUtility.formatPath(autolabview.getPrinterObj().getExportRealPath()));
                            if (exportPath.equals("") == false) {
                                if (exportPath.substring(exportPath.length() - 1)
                                        .equals(File.separator) == false) {
                                    exportPath = exportPath + File.separator;
                                }
                            } else {
                                exportPath = Common.interface_output_path + "Auto Labeller" + File.separator;
                            }

                            String exportFilename = exportPath
                                    + JUtility.removePathSeparators(autolabview.getAutoLabellerObj().getLine())
                                    + "_"
                                    + JUtility.removePathSeparators(autolabview.getPrinterObj().getPrinterID())
                                    + "." + autolabview.getPrinterObj().getExportFormat();

                            String exportFilenameTemp = exportFilename + ".out";

                            logger.debug("Export Filename  =" + exportFilename);

                            /* ================CSV================ */

                            if (autolabview.getPrinterObj().getExportFormat().equals("CSV")) {
                                try {
                                    PreparedStatement stmt = null;
                                    ResultSet rs;
                                    String labelType = autolabview.getLabelDataObj().getLabelType();
                                    stmt = Common.hostList.getHost(getHostID()).getConnection(getSessionID())
                                            .prepareStatement(
                                                    Common.hostList.getHost(getHostID()).getSqlstatements()
                                                            .getSQL("DBVIEW_AUTO_LABELLER_PRINTER.getProperties"
                                                                    + "_" + labelType));
                                    stmt.setString(1, autolabview.getAutoLabellerObj().getLine());
                                    stmt.setString(2, autolabview.getPrinterObj().getPrinterID());
                                    stmt.setFetchSize(50);

                                    rs = stmt.executeQuery();

                                    logger.debug("Writing CSV");

                                    CSVWriter writer = new CSVWriter(new FileWriter(exportFilenameTemp),
                                            CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER,
                                            CSVWriter.DEFAULT_ESCAPE_CHARACTER, CSVWriter.DEFAULT_LINE_END);

                                    writer.writeAll(rs, true);

                                    rs.close();

                                    stmt.close();

                                    writer.close();

                                    File fromFile = new File(exportFilenameTemp);
                                    File toFile = new File(exportFilename);

                                    FileUtils.deleteQuietly(toFile);
                                    FileUtils.moveFile(fromFile, toFile);

                                    fromFile = null;
                                    toFile = null;

                                } catch (Exception e) {
                                    messageProcessedOK = false;
                                    messageError = e.getMessage();
                                }
                            }

                            /* ================XML================ */

                            if (autolabview.getPrinterObj().getExportFormat().equals("XML")) {
                                try {
                                    PreparedStatement stmt = null;
                                    ResultSet rs;

                                    stmt = Common.hostList.getHost(getHostID()).getConnection(getSessionID())
                                            .prepareStatement(Common.hostList.getHost(getHostID())
                                                    .getSqlstatements()
                                                    .getSQL("DBVIEW_AUTO_LABELLER_PRINTER.getProperties"));
                                    stmt.setString(1, autolabview.getAutoLabellerObj().getLine());
                                    stmt.setString(2, autolabview.getPrinterObj().getPrinterID());
                                    stmt.setFetchSize(50);

                                    rs = stmt.executeQuery();
                                    ResultSetMetaData rsmd = rs.getMetaData();
                                    int colCount = rsmd.getColumnCount();

                                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                                    DocumentBuilder builder = factory.newDocumentBuilder();
                                    Document document = builder.newDocument();

                                    Element message = (Element) document.createElement("message");

                                    Element hostUniqueID = addElement(document, "hostRef",
                                            Common.hostList.getHost(getHostID()).getUniqueID());
                                    message.appendChild(hostUniqueID);

                                    Element messageRef = addElement(document, "messageRef",
                                            autolabview.getAutoLabellerObj().getUniqueID());
                                    message.appendChild(messageRef);

                                    Element messageType = addElement(document, "interfaceType",
                                            "Auto Labeller Data");
                                    message.appendChild(messageType);

                                    Element messageInformation = addElement(document, "messageInformation",
                                            "Unique ID=" + autolabview.getAutoLabellerObj().getUniqueID());
                                    message.appendChild(messageInformation);

                                    Element messageDirection = addElement(document, "interfaceDirection",
                                            "Output");
                                    message.appendChild(messageDirection);

                                    Element messageDate = addElement(document, "messageDate",
                                            JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime()));
                                    message.appendChild(messageDate);

                                    if (rs.first()) {

                                        Element labelData = (Element) document.createElement("LabelData");

                                        Element row = document.createElement("Row");
                                        labelData.appendChild(row);
                                        for (int i = 1; i <= colCount; i++) {
                                            String columnName = rsmd.getColumnName(i);
                                            Object value = rs.getObject(i);
                                            Element node = document.createElement(columnName);
                                            node.appendChild(document.createTextNode(value.toString()));
                                            row.appendChild(node);
                                        }

                                        message.appendChild(labelData);

                                        document.appendChild(message);

                                        JXMLDocument xmld = new JXMLDocument();
                                        xmld.setDocument(document);

                                        // ===============================

                                        DOMImplementationLS DOMiLS = null;
                                        FileOutputStream FOS = null;

                                        // testing the support for DOM
                                        // Load and Save
                                        if ((document.getFeature("Core", "3.0") != null)
                                                && (document.getFeature("LS", "3.0") != null)) {
                                            DOMiLS = (DOMImplementationLS) (document.getImplementation())
                                                    .getFeature("LS", "3.0");

                                            // get a LSOutput object
                                            LSOutput LSO = DOMiLS.createLSOutput();

                                            FOS = new FileOutputStream(exportFilename);
                                            LSO.setByteStream((OutputStream) FOS);

                                            // get a LSSerializer object
                                            LSSerializer LSS = DOMiLS.createLSSerializer();

                                            // do the serialization
                                            LSS.write(document, LSO);

                                            FOS.close();
                                        }

                                        // ===============================

                                    }
                                    rs.close();
                                    stmt.close();

                                } catch (Exception e) {
                                    messageError = e.getMessage();
                                }

                            }

                            if (autolabview.getPrinterObj().getExportFormat().equals("LQF")) {

                            }
                        }

                        if (autolabview.getPrinterObj().isDirectPrintEnabled()) {

                        }

                    }

                    if (messageProcessedOK == true) {
                        autolabview.getAutoLabellerObj().setModified(false);
                        autolabview.getAutoLabellerObj().update();
                    } else {
                        logger.debug(messageError);
                    }

                    autolabview = null;
                }
            }
        }
    }
}

From source file:org.apache.tajo.scheduler.FairScheduler.java

private void reorganizeQueue(List<QueueProperty> newQueryList) {
    Set<String> previousQueueNames = new HashSet<String>(queues.keySet());

    for (QueueProperty eachQueue : newQueryList) {
        queueProperties.put(eachQueue.getQueueName(), eachQueue);
        if (!previousQueueNames.remove(eachQueue.getQueueName())) {
            // not existed queue
            LinkedList<QuerySchedulingInfo> queue = new LinkedList<QuerySchedulingInfo>();
            queues.put(eachQueue.getQueueName(), queue);
            LOG.info("Queue [" + eachQueue + "] added");
        }//from   w w  w  . j a v  a  2  s . c  o  m
    }

    // Removed queue
    for (String eachRemovedQueue : previousQueueNames) {
        queueProperties.remove(eachRemovedQueue);

        LinkedList<QuerySchedulingInfo> queue = queues.remove(eachRemovedQueue);
        LOG.info("Queue [" + eachRemovedQueue + "] removed");
        if (queue != null) {
            for (QuerySchedulingInfo eachQuery : queue) {
                LOG.warn("Remove waiting query: " + eachQuery + " from " + eachRemovedQueue + " queue");
            }
        }

        queue.clear();
    }
}

From source file:org.red5.server.net.rtmpt.BaseRTMPTConnection.java

protected IoBuffer foldPendingMessages(int targetSize) {
    log.debug("foldPendingMessages - target size: {}", targetSize);
    IoBuffer result = null;//from ww w  .  j  a va2 s . c o  m
    if (!pendingOutMessages.isEmpty()) {
        int available = pendingOutMessages.size();
        // create list to hold outgoing data
        LinkedList<PendingData> sendList = new LinkedList<PendingData>();
        pendingOutMessages.drainTo(sendList, Math.min(164, available));
        result = IoBuffer.allocate(targetSize).setAutoExpand(true);
        for (PendingData pendingMessage : sendList) {
            result.put(pendingMessage.getBuffer());
            Packet packet = pendingMessage.getPacket();
            if (packet != null) {
                try {
                    handler.messageSent(this, packet);
                    // mark packet as being written
                    writingMessage(packet);
                } catch (Exception e) {
                    log.error("Could not notify stream subsystem about sent message", e);
                }
            } else {
                log.trace("Pending message did not have a packet");
            }
        }
        sendList.clear();
        result.flip();
        // send byte length
        if (log.isDebugEnabled()) {
            log.debug("Send size: {}", result.limit());
        }
    }
    return result;
}

From source file:com.commander4j.db.JDBDespatch.java

public LinkedList<String> getAssignedSSCCs(String despatchNo) {
    PreparedStatement stmt = null;
    LinkedList<String> result = new LinkedList<String>();
    ResultSet rs;//  w  ww . j  av a2 s .  co m

    result.clear();

    try {
        stmt = Common.hostList.getHost(getHostID()).getConnection(getSessionID()).prepareStatement(
                Common.hostList.getHost(getHostID()).getSqlstatements().getSQL("JDBDespatch.getAssignedSSCCs"));
        stmt.setFetchSize(50);
        stmt.setString(1, despatchNo);

        rs = stmt.executeQuery();

        while (rs.next()) {
            result.addLast(rs.getString("SSCC"));
        }

        rs.close();

        stmt.close();
    } catch (SQLException e) {
        setErrorMessage(e.getMessage());
    }

    return result;
}

From source file:org.apache.accumulo.gc.GarbageCollectWriteAheadLogsTest.java

@Test
public void replicationEntriesAffectGC() throws Exception {
    String file1 = UUID.randomUUID().toString(), file2 = UUID.randomUUID().toString();
    Connector conn = createMock(Connector.class);

    // Write a Status record which should prevent file1 from being deleted
    LinkedList<Entry<Key, Value>> replData = new LinkedList<>();
    replData.add(Maps.immutableEntry(new Key("/wals/" + file1, StatusSection.NAME.toString(), "1"),
            StatusUtil.fileCreatedValue(System.currentTimeMillis())));

    ReplicationGCWAL replGC = new ReplicationGCWAL(null, volMgr, false, replData);

    replay(conn);//from   w  ww  . j a va 2 s.  c  o  m

    // Open (not-closed) file must be retained
    assertTrue(replGC.neededByReplication(conn, "/wals/" + file1));

    // No replication data, not needed
    replData.clear();
    assertFalse(replGC.neededByReplication(conn, "/wals/" + file2));

    // The file is closed but not replicated, must be retained
    replData.add(Maps.immutableEntry(new Key("/wals/" + file1, StatusSection.NAME.toString(), "1"),
            StatusUtil.fileClosedValue()));
    assertTrue(replGC.neededByReplication(conn, "/wals/" + file1));

    // File is closed and fully replicated, can be deleted
    replData.clear();
    replData.add(Maps.immutableEntry(new Key("/wals/" + file1, StatusSection.NAME.toString(), "1"),
            ProtobufUtil.toValue(Status.newBuilder().setInfiniteEnd(true).setBegin(Long.MAX_VALUE)
                    .setClosed(true).build())));
    assertFalse(replGC.neededByReplication(conn, "/wals/" + file1));
}