Package net.yacy.cora.services.federated.solr

Examples of net.yacy.cora.services.federated.solr.SolrScheme


                // switch off
                sb.solrConnector.close();
                sb.solrConnector = null;
            }

            final SolrScheme scheme = new SolrScheme(new File(env.getDataPath(), "DATA/SETTINGS/" + schemename));

            if (solrIsOnAfterwards) {
                // switch on
                final boolean usesolr = sb.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
                try {
                    sb.solrConnector = (usesolr) ? new SolrChardingConnector(solrurls, scheme, SolrChardingSelection.Method.MODULO_HOST_MD5) : null;
                } catch (final IOException e) {
                    Log.logException(e);
                    sb.solrConnector = null;
                }
            }

            // read index scheme table flags
            final Iterator<ConfigurationSet.Entry> i = scheme.allIterator();
            ConfigurationSet.Entry entry;
            while (i.hasNext()) {
                entry = i.next();
                final String v = post.get("scheme_" + entry.key());
                final boolean c = v != null && v.equals("checked");
                try {
                    if (entry.enabled()) {
                        if (!c) scheme.disable(entry.key());
                    } else {
                        if (c) scheme.enable(entry.key());
                    }
                } catch (final IOException e) {}
            }
        }

        // show solr host table
        if (sb.solrConnector == null) {
            prop.put("table", 0);
        } else {
            prop.put("table", 1);
            final long[] size = sb.solrConnector.getSizeList();
            final String[] urls = sb.solrConnector.getAdminInterfaceList();
            boolean dark = false;
            for (int i = 0; i < size.length; i++) {
                prop.put("table_list_" + i + "_dark", dark ? 1 : 0); dark = !dark;
                prop.put("table_list_" + i + "_url", urls[i]);
                prop.put("table_list_" + i + "_size", size[i]);
            }
            prop.put("table_list", size.length);
        }

        // write scheme
        SolrScheme scheme = (sb.solrConnector == null) ? null : sb.solrConnector.getScheme();
        final String schemename = sb.getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list");
        if (scheme == null) {
            scheme = new SolrScheme(new File(env.getDataPath(), "DATA/SETTINGS/" + schemename));
        }
        final Iterator<ConfigurationSet.Entry> i = scheme.allIterator();
        int c = 0;
        boolean dark = false;
        ConfigurationSet.Entry entry;
        while (i.hasNext()) {
            entry = i.next();
            prop.put("scheme_" + c + "_dark", dark ? 1 : 0); dark = !dark;
            prop.put("scheme_" + c + "_checked", scheme.contains(entry.key()) ? 1 : 0);
            prop.putHTML("scheme_" + c + "_key", entry.key());
            prop.putHTML("scheme_" + c + "_comment", scheme.commentHeadline(entry.key()));
            c++;
        }
        prop.put("scheme", c);

        // fill attribute fields
View Full Code Here


        // prepare a solr index profile switch list
        final File solrBackupProfile = new File("defaults/solr.keys.list");
        final String schemename = getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list");
        final File solrWorkProfile = new File(getDataPath(), "DATA/SETTINGS/" + schemename);
        if (!solrWorkProfile.exists()) FileUtils.copy(solrBackupProfile, solrWorkProfile);
        final SolrScheme backupScheme = new SolrScheme(solrBackupProfile);
        final SolrScheme workingScheme = new SolrScheme(solrWorkProfile);

        // update the working scheme with the backup scheme. This is necessary to include new features.
        // new features are always activated by default
        workingScheme.fill(backupScheme);

        // set up the solr interface
        final String solrurls = getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr");
        final boolean usesolr = getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
        try {
View Full Code Here

                // switch off
                sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).getSolr().close();
                sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).connectSolr(null);
            }

            final SolrScheme scheme = new SolrScheme(new File(env.getDataPath(), "DATA/SETTINGS/" + schemename));

            if (solrIsOnAfterwards) {
                // switch on
                final boolean usesolr = sb.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
                try {
                    sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).connectSolr((usesolr) ? new SolrShardingConnector(solrurls, scheme, SolrShardingSelection.Method.MODULO_HOST_MD5, 10000) : null);
                } catch (final IOException e) {
                    Log.logException(e);
                    sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).connectSolr(null);
                }
            }

            // read index scheme table flags
            final Iterator<ConfigurationSet.Entry> i = scheme.allIterator();
            ConfigurationSet.Entry entry;
            while (i.hasNext()) {
                entry = i.next();
                final String v = post.get("scheme_" + entry.key());
                final boolean c = v != null && v.equals("checked");
                try {
                    if (entry.enabled()) {
                        if (!c) scheme.disable(entry.key());
                    } else {
                        if (c) scheme.enable(entry.key());
                    }
                } catch (final IOException e) {}
            }
        }

        // show solr host table
        if (sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).getSolr() == null) {
            prop.put("table", 0);
        } else {
            prop.put("table", 1);
            final SolrConnector solr = sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).getSolr();
            final long[] size = (solr instanceof SolrShardingConnector) ? ((SolrShardingConnector) solr).getSizeList() : new long[]{((SolrSingleConnector) solr).getSize()};
            final String[] urls = (solr instanceof SolrShardingConnector) ? ((SolrShardingConnector) solr).getAdminInterfaceList() : new String[]{((SolrSingleConnector) solr).getAdminInterface()};
            boolean dark = false;
            for (int i = 0; i < size.length; i++) {
                prop.put("table_list_" + i + "_dark", dark ? 1 : 0); dark = !dark;
                prop.put("table_list_" + i + "_url", urls[i]);
                prop.put("table_list_" + i + "_size", size[i]);
            }
            prop.put("table_list", size.length);
        }

        // write scheme
        SolrScheme scheme = (sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).getSolr() == null) ? null : sb.indexSegments.segment(Segments.Process.LOCALCRAWLING).getSolr().getScheme();
        final String schemename = sb.getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list");
        if (scheme == null) {
            scheme = new SolrScheme(new File(env.getDataPath(), "DATA/SETTINGS/" + schemename));
        }
        final Iterator<ConfigurationSet.Entry> i = scheme.allIterator();
        int c = 0;
        boolean dark = false;
        ConfigurationSet.Entry entry;
        while (i.hasNext()) {
            entry = i.next();
            prop.put("scheme_" + c + "_dark", dark ? 1 : 0); dark = !dark;
            prop.put("scheme_" + c + "_checked", scheme.contains(entry.key()) ? 1 : 0);
            prop.putHTML("scheme_" + c + "_key", entry.key());
            prop.putHTML("scheme_" + c + "_comment", scheme.commentHeadline(entry.key()));
            c++;
        }
        prop.put("scheme", c);

        // fill attribute fields
View Full Code Here

        // prepare a solr index profile switch list
        final File solrBackupProfile = new File("defaults/solr.keys.list");
        final String schemename = getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list");
        final File solrWorkProfile = new File(getDataPath(), "DATA/SETTINGS/" + schemename);
        if (!solrWorkProfile.exists()) FileUtils.copy(solrBackupProfile, solrWorkProfile);
        final SolrScheme backupScheme = new SolrScheme(solrBackupProfile);
        final SolrScheme workingScheme = new SolrScheme(solrWorkProfile);

        // update the working scheme with the backup scheme. This is necessary to include new features.
        // new features are always activated by default
        workingScheme.fill(backupScheme);

        // set up the solr interface
        final String solrurls = getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr");
        final boolean usesolr = getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
        try {
View Full Code Here

TOP

Related Classes of net.yacy.cora.services.federated.solr.SolrScheme

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.