Package de.anomic.search

Examples of de.anomic.search.Switchboard$receiptSending


        return SimpleFormatter.format(date);
    }


    public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) throws IOException {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        if (post == null) {
            post = new serverObjects();
            post.put("page", "start");
        }

        prop.put("topmenu", sb.getConfigBool("publicTopmenu", true) ? 1 : 0);
       
        String access = sb.getConfig("WikiAccess", "admin");
        final String pagename = get(post, "page", "start");
        final String ip = get(post, HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
        String author = get(post, "author", ANONYMOUS);
        if (author.equals(ANONYMOUS)) {
            author = WikiBoard.guessAuthor(ip);
            if (author == null) {
                author = (sb.peers.mySeed() == null) ? ANONYMOUS : sb.peers.mySeed().get("Name", ANONYMOUS);
            }
        }
       
        if (post != null && post.containsKey("access")) {
            // only the administrator may change the access right
            if (!sb.verifyAuthentication(header, true)) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }
           
            access = post.get("access", "admin");
            sb.setConfig("WikiAccess", access);
        }
        if (access.equals("admin")) {
            prop.put("mode_access", "0");
        } else if (access.equals("all")) {
            prop.put("mode_access", "1");
        }

        WikiBoard.Entry page = sb.wikiDB.read(pagename);
       
        if (post != null && post.containsKey("submit")) {
           
            if ((access.equals("admin") && (!sb.verifyAuthentication(header, true)))) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }
           
            // store a new page
            byte[] content;
            content = UTF8.getBytes(post.get("content", ""));
            final WikiBoard.Entry newEntry = sb.wikiDB.newEntry(pagename, author, ip, post.get("reason", "edit"), content);
            sb.wikiDB.write(newEntry);
            // create a news message
            final Map<String, String> map = new HashMap<String, String>();
            map.put("page", pagename);
            map.put("author", author.replace(',', ' '));
            if (!sb.isRobinsonMode() && post.get("content", "").trim().length() > 0 && !ByteBuffer.equals(page.page(), content)) {
                sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), yacyNewsPool.CATEGORY_WIKI_UPDATE, map);
            }
            page = newEntry;
            prop.putHTML("LOCATION", "/Wiki.html?page=" + pagename);
            prop.put("LOCATION", prop.get("LOCATION"));
        }
       
        if (post != null && post.containsKey("edit")) {
            if ((access.equals("admin") && (!sb.verifyAuthentication(header, true)))) {
                // check access right for admin
                prop.put("AUTHENTICATE", "admin log-in"); // force log-in
                return prop;
            }
           
View Full Code Here


public class CrawlResults {

    public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
        // return variable that accumulates replacements
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();

        int lines = 500;
        boolean showInit = env.getConfigBool("IndexMonitorInit", false);
        boolean showExec = env.getConfigBool("IndexMonitorExec", false);
        boolean showDate = env.getConfigBool("IndexMonitorDate", true);
        boolean showWords = env.getConfigBool("IndexMonitorWords", true);
        boolean showTitle = env.getConfigBool("IndexMonitorTitle", true);
        boolean showURL = env.getConfigBool("IndexMonitorURL", true);

        if (post == null) {
            post = new serverObjects();
            post.put("process", "0");
        }

        // find process number
        EventOrigin tabletype;
        try {
            tabletype = EventOrigin.getEvent(post.getInt("process", 0));
        } catch (final NumberFormatException e) {
            tabletype = EventOrigin.UNKNOWN;
        }

        if (
            post != null &&
            post.containsKey("autoforward") &&
            tabletype == EventOrigin.LOCAL_CRAWLING &&
            ResultURLs.getStackSize(EventOrigin.LOCAL_CRAWLING) == 0) {
            // the main menu does a request to the local crawler page, but in case this table is empty, the overview page is shown
            tabletype = (ResultURLs.getStackSize(EventOrigin.SURROGATES) == 0) ? EventOrigin.UNKNOWN : EventOrigin.SURROGATES;
        }
       
        // check if authorization is needed and/or given
        if (tabletype != EventOrigin.UNKNOWN ||
            (post != null && (post.containsKey("clearlist") ||
            post.containsKey("deleteentry")))) {
            final String authorization = (header.get(RequestHeader.AUTHORIZATION, "xxxxxx"));
            if (authorization.length() != 0) {
                if (! sb.verifyAuthentication(header, true)){
                    // force log-in (again, because wrong password was given)
                    prop.put("AUTHENTICATE", "admin log-in");
                    return prop;
                }
            } else {
View Full Code Here

import de.anomic.server.serverSwitch;

public class DictionaryLoader_p {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects(); // return variable that accumulates replacements

        /*
         * distinguish the following cases:
         * - dictionary file was not loaded -> actions: load the file
View Full Code Here

    public static final int STATUS_PARSE_ERROR = 6;

    private final static String BLACKLIST_FILENAME_FILTER = "^.*\\.black$";
   
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        // return variable that accumulates replacements
        final serverObjects prop = new serverObjects();

        // get the name of the destination blacklist
        String selectedBlacklistName = "";
View Full Code Here

    public static String dateString(final Date date) {
        return SIMPLE_FORMATTER.format(date);
    }

    public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        boolean hasRights = sb.verifyAuthentication(header, true);

        prop.put("mode_admin", hasRights ? "1" : "0");

        if (post == null) {
            post = new serverObjects();
            post.put("page", "blog_default");
        }

        if (!hasRights) {
            final UserDB.Entry userentry = sb.userDB.proxyAuth(header.get(RequestHeader.AUTHORIZATION, "xxxxxx"));
            if (userentry != null && userentry.hasRight(UserDB.AccessRight.BLOG_RIGHT)) {
                hasRights = true;
            }
            //opens login window if login link is clicked
            else if (post.containsKey("login")) {
                prop.put("AUTHENTICATE","admin log-in");
            }
        }

        final String pagename = post.get("page", "blog_default");
        final String ip = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");

        String StrAuthor = post.get("author", "anonymous");

        if ("anonymous".equals(StrAuthor)) {
            StrAuthor = sb.blogDB.guessAuthor(ip);

            if (StrAuthor == null || StrAuthor.length() == 0) {
                if (sb.peers.mySeed() == null) {
                    StrAuthor = "anonymous";
                } else {
                    StrAuthor = sb.peers.mySeed().get("Name", "anonymous");
                }
            }
        }

        byte[] author;
        author = UTF8.getBytes(StrAuthor);

        final BlogBoard.BlogEntry page = sb.blogDB.readBlogEntry(pagename); //maybe "if(page == null)"
        final boolean pageExists = sb.blogDB.contains(pagename);
       
        // comments not allowed
        prop.put("mode_allow", (page.getCommentMode() == 0) ? 0 : 1);

        if (post.containsKey("submit") && page.getCommentMode() != 0 && pageExists) {
            // store a new/edited blog-entry
            byte[] content;
            if (!"".equals(post.get("content", ""))) {
                if ("".equals(post.get("subject", ""))) {
                    post.putHTML("subject", "no title");
                }
                content = UTF8.getBytes(post.get("content", ""));

                final Date date = null;

                //set name for new entry or date for old entry
                final String StrSubject = post.get("subject", "");
                byte[] subject;
                subject = UTF8.getBytes(StrSubject);
                final String commentID = String.valueOf(System.currentTimeMillis());
                final BlogEntry blogEntry = sb.blogDB.readBlogEntry(pagename);
                blogEntry.addComment(commentID);
                sb.blogDB.writeBlogEntry(blogEntry);
                sb.blogCommentDB.write(sb.blogCommentDB.newEntry(commentID, subject, author, ip, date, content));
                prop.putHTML("LOCATION","BlogComments.html?page=" + pagename);

                MessageBoard.entry msgEntry = null;
                sb.messageDB.write(msgEntry = sb.messageDB.newEntry(
                        "blogComment",
                        StrAuthor,
                        sb.peers.mySeed().hash,
                        sb.peers.mySeed().getName(), sb.peers.mySeed().hash,
                        "new blog comment: " + UTF8.String(blogEntry.getSubject()), content));

                messageForwardingViaEmail(sb, msgEntry);

                // finally write notification
                final File notifierSource = new File(sb.getAppPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");
                final File notifierDest   = new File(sb.getDataPath("htDocsPath", "DATA/HTDOCS"), "notifier.gif");
                try {
                    FileUtils.copy(notifierSource, notifierDest);
                } catch (final IOException e) {
                    Log.logSevere("MESSAGE", "NEW MESSAGE ARRIVED! (error: " + e.getMessage() + ")");
View Full Code Here

import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;

public class YMarks {
  public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
        final UserDB.Entry user = sb.userDB.getUser(header);
        final boolean isAdmin = (sb.verifyAuthentication(header, true));
        final boolean isAuthUser = user!= null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT);
       
        if(isAdmin || isAuthUser) {
          prop.put("login", 1);
          String bmk_user = (isAuthUser ? user.getUserName() : YMarkTables.USER_ADMIN);
View Full Code Here

import de.anomic.server.serverSwitch;

public class Table_API_p {
   
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();
       
        prop.put("showexec", 0);
        prop.put("showtable", 0);
       
        int startRecord = 0;
        int maximumRecords = 25;
        Pattern query = QueryParams.catchall_pattern;
        if (post != null && post.containsKey("startRecord")) startRecord = post.getInt("startRecord", 0);
        if (post != null && post.containsKey("maximumRecords")) maximumRecords = post.getInt("maximumRecords", 0);
        if (post != null && post.containsKey("query") && !post.get("query", "").isEmpty()) {
            query = Pattern.compile(".*" + post.get("query", "") + ".*");
            startRecord = 0;
            maximumRecords = 1000;
        }
        final boolean inline = (post != null && post.getBoolean("inline",false));

        prop.put("inline", (inline) ? 1 : 0);
       
        Pattern typefilter = QueryParams.catchall_pattern;
        if (post != null && post.containsKey("filter") && post.get("filter", "").length() > 0) {
            typefilter = Pattern.compile(post.get("filter", ".*"));
        }
       
        String pk;
        if (post != null && post.containsKey("repeat_select") && ((pk = post.get("pk")) != null)) try {
            final String action = post.get("repeat_select", "off");
            if (action.equals("on")) {
                Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes());
                if (row != null) {
                    row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 7);
                    row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, "days");
                    WorkTables.calculateAPIScheduler(row, false);
                    sb.tables.update(WorkTables.TABLE_API_NAME, row);
                }
            }
        } catch (IOException e) {
            Log.logException(e);
        } catch (RowSpaceExceededException e) {
            Log.logException(e);
        }
       
        if (post != null && post.containsKey("repeat_time") && ((pk = post.get("pk")) != null)) try {
            final String action = post.get("repeat_time", "off");
            final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes());
            if (row != null) {
                if ("off".equals(action)) {
                    row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0);
                } else {
                    row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, Integer.parseInt(action));
                }
                WorkTables.calculateAPIScheduler(row, false);
                sb.tables.update(WorkTables.TABLE_API_NAME, row);
            }
        } catch (IOException e) {
            Log.logException(e);
        } catch (RowSpaceExceededException e) {
            Log.logException(e);
        }
       
        if (post != null && post.containsKey("repeat_unit") && ((pk = post.get("pk")) != null)) try {
            final String action = post.get("repeat_unit", "seldays");
            final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes());
            if (row != null) {
                int time = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 1);
                row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, action.substring(3));
                if (action.equals("selminutes") && time > 0 && time < 10) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 10);
                if (action.equals("selminutes") && time > 50) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 50);
                if (action.equals("selhours") && time > 23) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 23);
                if (action.equals("seldays") && time > 30) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 30);
                WorkTables.calculateAPIScheduler(row, false);
                sb.tables.update(WorkTables.TABLE_API_NAME, row);
            }
        } catch (IOException e) {
            Log.logException(e);
        } catch (RowSpaceExceededException e) {
            Log.logException(e);
        }
       
        if (post != null && !post.get("deleterows", "").isEmpty()) {
            for (final Map.Entry<String, String> entry: post.entrySet()) {
                if (entry.getValue().startsWith("mark_")) {
                    try {
                        sb.tables.delete(WorkTables.TABLE_API_NAME, entry.getValue().substring(5).getBytes());
                    } catch (IOException e) {
                        Log.logException(e);
                    }
                }
            }
        }

        if (post != null && !post.get("execrows", "").isEmpty()) {
            // create a time-ordered list of events to execute
            final Set<String> pks = new TreeSet<String>();
            for (final Map.Entry<String, String> entry: post.entrySet()) {
                if (entry.getValue().startsWith("mark_")) {
                    pks.add(entry.getValue().substring(5));
                }
            }
           
            // now call the api URLs and store the result status
            final Map<String, Integer> l = sb.tables.execAPICalls("localhost", (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
           
            // construct result table
            prop.put("showexec", l.size() > 0 ? 1 : 0);
           
            final Iterator<Map.Entry<String, Integer>> resultIterator = l.entrySet().iterator();
            Map.Entry<String, Integer> record;
            int count = 0;
            boolean dark = true;
            while (resultIterator.hasNext()) {
                record = resultIterator.next();
                if (record == null) continue;
                prop.put("showexec_list_" + count + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
                prop.put("showexec_list_" + count + "_status", record.getValue());
                prop.put("showexec_list_" + count + "_url", record.getKey());
                count++;
            }
            prop.put("showexec_list", count);
        }
       
        // generate table
        prop.put("showtable", 1);
        prop.put("showtable_inline", inline ? 1 : 0);
       
        // insert rows
        final List<Tables.Row> table = new ArrayList<Tables.Row>(maximumRecords);
        int count = 0;
        int tablesize = 0;
        try {
            tablesize = sb.tables.size(WorkTables.TABLE_API_NAME);
            final Iterator<Tables.Row> plainIterator = sb.tables.iterator(WorkTables.TABLE_API_NAME);
            final Iterator<Tables.Row> mapIterator = sb.tables.orderBy(plainIterator, -1, WorkTables.TABLE_API_COL_DATE_RECORDING).iterator();
            Tables.Row r;
            boolean dark = true;
            boolean scheduledactions = false;
            int c = 0;
            String type, comment;
            // first prepare a list
            while (mapIterator.hasNext()) {
                r = mapIterator.next();
                if (r == null) continue;
                type = UTF8.String(r.get(WorkTables.TABLE_API_COL_TYPE));
                if (!typefilter.matcher(type).matches()) continue;
                comment = UTF8.String(r.get(WorkTables.TABLE_API_COL_COMMENT));
                if (!query.matcher(comment).matches()) continue;
                if (c >= startRecord) table.add(r);
                c++;
                if (table.size() >= maximumRecords) break;
            }
            // then work on the list
            for (final Tables.Row row: table) {
                final Date now = new Date();
                final Date date = row.containsKey(WorkTables.TABLE_API_COL_DATE) ? row.get(WorkTables.TABLE_API_COL_DATE, now) : null;
                final Date date_recording = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, date);
                final Date date_last_exec = row.get(WorkTables.TABLE_API_COL_DATE_LAST_EXEC, date);
                final Date date_next_exec = row.get(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, (Date) null);
                final int callcount = row.get(WorkTables.TABLE_API_COL_APICALL_COUNT, 1);
                final String unit = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, "days");
                final int time = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0);
                prop.put("showtable_list_" + count + "_inline", inline ? 1 : 0);
                prop.put("showtable_list_" + count + "_dark", dark ? 1 : 0); dark=!dark;
                prop.put("showtable_list_" + count + "_pk", UTF8.String(row.getPK()));
                prop.put("showtable_list_" + count + "_count", count);
                prop.put("showtable_list_" + count + "_callcount", callcount);
                prop.put("showtable_list_" + count + "_dateRecording", date_recording == null ? "-" : DateFormat.getDateTimeInstance().format(date_recording));
                prop.put("showtable_list_" + count + "_dateLastExec",  date_last_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_last_exec));
                prop.put("showtable_list_" + count + "_dateNextExec",  date_next_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_next_exec));
                prop.put("showtable_list_" + count + "_selectedMinutes", unit.equals("minutes") ? 1 : 0);
                prop.put("showtable_list_" + count + "_selectedHours", unit.equals("hours") ? 1 : 0);
                prop.put("showtable_list_" + count + "_selectedDays", (unit.length() == 0 || unit.equals("days")) ? 1 : 0);
                prop.put("showtable_list_" + count + "_repeatTime", time);
                prop.put("showtable_list_" + count + "_type", row.get(WorkTables.TABLE_API_COL_TYPE));
                prop.put("showtable_list_" + count + "_comment", row.get(WorkTables.TABLE_API_COL_COMMENT));
                prop.putHTML("showtable_list_" + count + "_inline_url", "http://" + sb.myPublicIP() + ":" + sb.getConfig("port", "8090") + UTF8.String(row.get(WorkTables.TABLE_API_COL_URL)));

                if (time == 0) {
                    prop.put("showtable_list_" + count + "_scheduler", 0);
                    prop.put("showtable_list_" + count + "_scheduler_pk", UTF8.String(row.getPK()));
                } else {
                    scheduledactions = true;
                    prop.put("showtable_list_" + count + "_scheduler", 1);
                    prop.put("showtable_list_" + count + "_scheduler_pk", UTF8.String(row.getPK()));
                    prop.put("showtable_list_" + count + "_scheduler_scale_" + 0 + "_time", "off");
                    prop.put("showtable_list_" + count + "_scheduler_selectedMinutes", 0);
                    prop.put("showtable_list_" + count + "_scheduler_selectedHours", 0);
                    prop.put("showtable_list_" + count + "_scheduler_selectedDays", 0);
                    if (unit.equals("minutes")) {
                        for (int i = 1; i <= 5 ; i++) {
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i * 10);
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0);
                        }
                        prop.put("showtable_list_" + count + "_scheduler_scale_" + (time / 10) + "_selected", 1);
                        prop.put("showtable_list_" + count + "_scheduler_scale", 6);
                        prop.put("showtable_list_" + count + "_scheduler_selectedMinutes", 1);
                    } else if (unit.equals("hours")) {
                        for (int i = 1; i <= 23 ; i++) {
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i);
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0);
                        }
                        prop.put("showtable_list_" + count + "_scheduler_scale_" + time + "_selected", 1);
                        prop.put("showtable_list_" + count + "_scheduler_scale", 24);
                        prop.put("showtable_list_" + count + "_scheduler_selectedHours", 1);
                    } else {
                        for (int i = 1; i <= 30 ; i++) {
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i);
                            prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0);
                        }
                        prop.put("showtable_list_" + count + "_scheduler_scale_" + time + "_selected", 1);
                        prop.put("showtable_list_" + count + "_scheduler_scale", 31);
                        prop.put("showtable_list_" + count + "_scheduler_selectedDays", 1);
                    }
                }
                prop.put("showtable_list_" + count + "_scheduler_inline", inline ? "true" : "false");
                prop.put("showtable_list_" + count + "_scheduler_filter", typefilter.pattern());
                prop.put("showtable_list_" + count + "_scheduler_query", query.pattern());
                prop.put("showtable_list_" + count + "_scheduler_startRecord", startRecord);
                prop.put("showtable_list_" + count + "_scheduler_maximumRecords", maximumRecords);
                count++;
            }
            if (scheduledactions) {
                prop.put("showschedulerhint", 1);
                prop.put("showschedulerhint_tfminutes", sb.getConfigLong(SwitchboardConstants.CLEANUP_BUSYSLEEP, 300000) / 60000);
            } else {
                prop.put("showschedulerhint", 0);
            }
        } catch (IOException e) {
            Log.logException(e);
View Full Code Here

public class ConfigHTCache_p {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) throws IOException {
        // return variable that accumulates replacements
        final Switchboard sb = (Switchboard) env;
        final serverObjects prop = new serverObjects();

        if (post != null && post.containsKey("set")) {
            // proxyCache - check and create the directory
            final String oldProxyCachePath = env.getConfig(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);
View Full Code Here

     * @return the rewrite-properties for the template
     */
    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {

        final serverObjects prop = new serverObjects();
        final Switchboard sb = (Switchboard) env;

        // get segment
        Segment indexSegment = null;
        if (post != null && post.containsKey("segment")) {
            final String segmentName = post.get("segment");
View Full Code Here

public class Threaddump_p {

    public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
     
      serverObjects prop = new serverObjects();
      Switchboard sb = (Switchboard) env;
     
      final StringBuilder buffer = new StringBuilder(1000);
     
      final boolean plain = post != null && post.getBoolean("plain", false);
      final int sleep = (post == null) ? 0 : post.getInt("sleep", 0); // a sleep before creation of a thread dump can be used for profiling
      if (sleep > 0) try {Thread.sleep(sleep);} catch (final InterruptedException e) {}
      prop.put("dump", "1");
      // Thread dump
      final Date dt = new Date();
      final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision();
      Runtime runtime = Runtime.getRuntime();
     
      ThreadDump.bufferappend(buffer, plain, "************* Start Thread Dump " + dt + " *******************");
      ThreadDump.bufferappend(buffer, plain, "");
      ThreadDump.bufferappend(buffer, plain, "YaCy Version: " + versionstring);
      ThreadDump.bufferappend(buffer, plain, "Assigned&nbsp;&nbsp;&nbsp;Memory = " + (runtime.maxMemory()));
      ThreadDump.bufferappend(buffer, plain, "Used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memory = " + (runtime.totalMemory() - runtime.freeMemory()));
      ThreadDump.bufferappend(buffer, plain, "Available&nbsp;&nbsp;Memory = " + (runtime.maxMemory() - runtime.totalMemory() + runtime.freeMemory()));
      ThreadDump.bufferappend(buffer, plain, "");
      ThreadDump.bufferappend(buffer, plain, "");
     
      int multipleCount = 100;
      File appPath = sb.getAppPath();
        if (post != null && post.containsKey("multipleThreaddump")) {
          multipleCount = post.getInt("count", multipleCount);
            final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<Map<Thread,StackTraceElement[]>>();
            for (int i = 0; i < multipleCount; i++) {
                try {
View Full Code Here

TOP

Related Classes of de.anomic.search.Switchboard$receiptSending

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.