Examples of OutputStreamStatement


Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

    public static void writeDynamicConfig(String dynamicConfigFilename, String configFileStr,
            final boolean configBackwardCompatibilityMode, final QuorumVerifier qv,
            final boolean needEraseStaticClientInfo) throws IOException {

        final String actualDynamicConfigFilename = dynamicConfigFilename;
        new AtomicFileWritingIdiom(new File(actualDynamicConfigFilename), new OutputStreamStatement() {
            @Override
            public void write(OutputStream outConfig) throws IOException {
                byte b[] = qv.toString().getBytes();
                outConfig.write(b);
            }
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

    /**
     * Backward compatibility -- It would backup static config file on bootup
     * if users write dynamic configuration in "zoo.cfg".
     */
    private void backupOldConfig() throws IOException {
        new AtomicFileWritingIdiom(new File(configFileStr + ".bak"), new OutputStreamStatement() {
            @Override
            public void write(OutputStream output) throws IOException {
                InputStream input = null;
                try {
                    input = new FileInputStream(new File(configFileStr));
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

    public void testOutputStreamSuccess() throws IOException {
        File target = new File(tmpdir, "target.txt");
        final File tmp = new File(tmpdir, "target.txt.tmp");
        createFile(target, "before");
        assertEquals("before", getContent(target));
        new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
            @Override
            public void write(OutputStream os) throws IOException {
                os.write("after".getBytes("ASCII"));
                assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
            }
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

        final File tmp = new File(tmpdir, "target.txt.tmp");
        createFile(target, "before");
        assertEquals("before", getContent(target));
        boolean exception = false;
        try {
            new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
                @Override
                public void write(OutputStream os) throws IOException {
                    os.write("after".getBytes("ASCII"));
                    os.flush();
                    assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

        final File tmp = new File(tmpdir, "target.txt.tmp");
        createFile(target, "before");
        assertEquals("before", getContent(target));
        boolean exception = false;
        try {
            new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
                @Override
                public void write(OutputStream os) throws IOException {
                    os.write("after".getBytes("ASCII"));
                    os.flush();
                    assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

        final File tmp = new File(tmpdir, "target.txt.tmp");
        createFile(target, "before");
        assertEquals("before", getContent(target));
        boolean exception = false;
        try {
            new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
                @Override
                public void write(OutputStream os) throws IOException {
                    os.write("after".getBytes("ASCII"));
                    os.flush();
                    assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

    public void testOutputStreamSuccessNE() throws IOException {
        File target = new File(tmpdir, "target.txt");
        final File tmp = new File(tmpdir, "target.txt.tmp");
        target.delete();
        assertFalse("file should not exist", target.exists());
        new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
            @Override
            public void write(OutputStream os) throws IOException {
                os.write("after".getBytes("ASCII"));
                assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
            }
View Full Code Here

Examples of org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement

        final File tmp = new File(tmpdir, "target.txt.tmp");
        target.delete();
        assertFalse("file should not exist", target.exists());
        boolean exception = false;
        try {
            new AtomicFileWritingIdiom(target, new OutputStreamStatement() {
                @Override
                public void write(OutputStream os) throws IOException {
                    os.write("after".getBytes("ASCII"));
                    os.flush();
                    assertTrue("implementation of AtomicFileOutputStream has changed, update the test", tmp.exists());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.