Package org.apache.bookkeeper.conf

Examples of org.apache.bookkeeper.conf.ServerConfiguration


            if (cmdLine.hasOption('h')) {
                throw new IllegalArgumentException();
            }

            ServerConfiguration conf = new ServerConfiguration();
            String[] leftArgs = cmdLine.getArgs();

            if (cmdLine.hasOption('c')) {
                if (null != leftArgs && leftArgs.length > 0) {
                    throw new IllegalArgumentException();
                }
                String confFile = cmdLine.getOptionValue("c");
                loadConfFile(conf, confFile);
                return conf;
            }

            if (leftArgs.length < 4) {
                throw new IllegalArgumentException();
            }

            // command line arguments overwrite settings in configuration file
            conf.setBookiePort(Integer.parseInt(leftArgs[0]));
            conf.setZkServers(leftArgs[1]);
            conf.setJournalDirName(leftArgs[2]);
            String[] ledgerDirNames = new String[leftArgs.length - 3];
            System.arraycopy(leftArgs, 3, ledgerDirNames, 0, ledgerDirNames.length);
            conf.setLedgerDirNames(ledgerDirNames);

            return conf;
        } catch (ParseException e) {
            LOG.error("Error parsing command line arguments : ", e);
            throw new IllegalArgumentException(e);
View Full Code Here


     * @throws IOException
     * @throws InterruptedException
     */
    public static void main(String[] args)
            throws IOException, KeeperException, InterruptedException {
        ServerConfiguration conf = null;
        try {
            conf = parseArgs(args);
        } catch (IllegalArgumentException iae) {
            LOG.error("Error parsing command line arguments : ", iae);
            System.err.println(iae.getMessage());
            printUsage();
            throw iae;
        }

        StringBuilder sb = new StringBuilder();
        String[] ledgerDirNames = conf.getLedgerDirNames();
        for (int i = 0; i < ledgerDirNames.length; i++) {
            if (i != 0) {
                sb.append(',');
            }
            sb.append(ledgerDirNames[i]);
        }

        String hello = String.format(
                           "Hello, I'm your bookie, listening on port %1$s. ZKServers are on %2$s. Journals are in %3$s. Ledgers are stored in %4$s.",
                           conf.getBookiePort(), conf.getZkServers(),
                           conf.getJournalDirName(), sb);
        LOG.info(hello);
        final BookieServer bs = new BookieServer(conf);
        bs.start();
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
View Full Code Here

    }
   
    public void startUpNewBookieServer() throws Exception {
        File tmpDir = FileUtils.createTempDirectory(
                PREFIX + (nextPort - initialPort), SUFFIX);
        ServerConfiguration conf = newServerConfiguration(
                nextPort++, hostPort, tmpDir, new File[] { tmpDir });
        BookieServer bs = new BookieServer(conf);
        bs.start();
        bookiesList.add(bs);
    }
View Full Code Here

        bs.start();
        bookiesList.add(bs);
    }

    protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir, File[] ledgerDirs) {
        ServerConfiguration conf = new ServerConfiguration(baseConf);
        conf.setBookiePort(port);
        conf.setZkServers(zkServers);
        conf.setJournalDirName(journalDir.getPath());
        String[] ledgerDirNames = new String[ledgerDirs.length];
        for (int i=0; i<ledgerDirs.length; i++) {
            ledgerDirNames[i] = ledgerDirs[i].getPath();
        }
        conf.setLedgerDirNames(ledgerDirNames);
        return conf;
    }
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Testing Journal Rolling without sync up");
        }

        // set flush interval to a large value
        ServerConfiguration newConf = new ServerConfiguration();
        newConf.setFlushInterval(999999999);
        // restart bookies
        restartBookies(newConf);

        // Write enough ledger entries so that we roll over journals
        LedgerHandle[] lhs = writeLedgerEntries(4, 1024, 1024);
View Full Code Here

    public static Collection<Object[]> configs() {
        return Arrays.asList(new Object[][] { {DigestType.MAC }, {DigestType.CRC32}});
    }

    protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir, File[] ledgerDirs) {
        ServerConfiguration conf = new ServerConfiguration(baseConf);
        conf.setBookiePort(port);
        conf.setZkServers(zkServers);
        conf.setJournalDirName(journalDir.getPath());
        String[] ledgerDirNames = new String[ledgerDirs.length];
        for (int i=0; i<ledgerDirs.length; i++) {
            ledgerDirNames[i] = ledgerDirs[i].getPath();
        }
        conf.setLedgerDirNames(ledgerDirNames);
        return conf;
    }
View Full Code Here

                File f = File.createTempFile("bookie", "test");
                tmpDirs.add(f);
                f.delete();
                f.mkdir();

                ServerConfiguration conf = newServerConfiguration(
                    initialPort + i, HOSTPORT, f, new File[] { f });
                bsConfs.add(conf);

                BookieServer server = new BookieServer(conf);
                server.start();
View Full Code Here

        bs.clear();
        Thread.sleep(1000);
        // restart them to ensure we can't
        int j = 0;
        for (File f : tmpDirs) {
            ServerConfiguration conf = bsConfs.get(j);
            if (null != newConf) {
                conf.loadConf(newConf);
            }
            BookieServer server = new BookieServer(conf);
            server.start();
            bs.add(server);
            j++;
View Full Code Here

    };

    @Test
    public void testProblemProcessor() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        conf.setBookiePort(22334);
        NIOServerFactory factory = new NIOServerFactory(conf, problemProcessor);
        Socket s = new Socket("127.0.0.1", 22334);
        s.setSoTimeout(5000);
        try {
            s.getOutputStream().write("\0\0\0\4\0\0\0\1".getBytes());
View Full Code Here

public class ConfigurationTest extends TestCase {
    @Test
    public void testConfigurationOverwrite() {
        System.clearProperty("zkServers");

        ServerConfiguration conf = new ServerConfiguration();
        assertEquals(null, conf.getZkServers());

        // override setting from property
        System.setProperty("zkServers", "server1");
        // it affects previous created configurations, if the setting is not overwrite
        assertEquals("server1", conf.getZkServers());

        ServerConfiguration conf2 = new ServerConfiguration();
        assertEquals("server1", conf2.getZkServers());

        System.clearProperty("zkServers");

        // load other configuration
        ServerConfiguration newConf = new ServerConfiguration();
        assertEquals(null, newConf.getZkServers());
        newConf.setZkServers("newserver");
        assertEquals("newserver", newConf.getZkServers());
        conf2.loadConf(newConf);
        assertEquals("newserver", conf2.getZkServers());
    }
View Full Code Here

TOP

Related Classes of org.apache.bookkeeper.conf.ServerConfiguration

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.