Package com.asakusafw.thundergate.runtime.cache

Examples of com.asakusafw.thundergate.runtime.cache.CacheStorage


    private FileProtocol.Kind deleteCacheData(String location) throws BulkLoaderSystemException {
        assert location != null;
        URI cacheBaseUri = FileNameUtil.createPath(getConf(), location, SURROGATE_EXECUTION_ID, userName).toUri();
        try {
            CacheStorage storage = new CacheStorage(getConf(), cacheBaseUri);
            try {
                boolean succeed;
                if (RuntimeContext.get().canExecute(storage)) {
                    succeed = storage.deleteAll();
                } else {
                    succeed = true;
                }
                return succeed ? FileProtocol.Kind.RESPONSE_DELETED : FileProtocol.Kind.RESPONSE_NOT_FOUND;
            } finally {
View Full Code Here


                "EXAMPLE",
                Collections.singleton("COL"),
                "com.example.Model",
                123L);

        CacheStorage storage = new CacheStorage(service.getConf(), uri("available"));
        try {
            storage.putHeadCacheInfo(info);
            assertThat(storage.getHeadCacheInfo(), is(notNullValue()));

            FileList.Reader reader = prepare("available");
            FileList.Writer writer = FileList.createWriter(writerBuffer, false);
            service.execute(reader, writer);
            writer.close();
            List<FileProtocol> results = collect(writerBuffer.toByteArray());
            assertThat(results.size(), is(1));
            assertThat(results.get(0).getLocation(), endsWith("available"));
            assertThat(results.get(0).getKind(), is(FileProtocol.Kind.RESPONSE_DELETED));

            assertThat(storage.getHeadCacheInfo(), is(nullValue()));
        } finally {
            storage.close();
        }
    }
View Full Code Here

                "EXAMPLE",
                Collections.singleton("COL"),
                "com.example.Model",
                123L);

        CacheStorage storage = new CacheStorage(service.getConf(), uri("available"));
        try {
            storage.putHeadCacheInfo(info);
            assertThat(storage.getHeadCacheInfo(), is(notNullValue()));

            FileList.Reader reader = prepare("nothing1", "nothing2", "available", "nothing3");
            FileList.Writer writer = FileList.createWriter(writerBuffer, false);
            service.execute(reader, writer);
            writer.close();
            List<FileProtocol> results = collect(writerBuffer.toByteArray());
            assertThat(results.size(), is(4));
            assertThat(results.get(0).getLocation(), endsWith("nothing1"));
            assertThat(results.get(0).getKind(), is(FileProtocol.Kind.RESPONSE_NOT_FOUND));
            assertThat(results.get(1).getLocation(), endsWith("nothing2"));
            assertThat(results.get(1).getKind(), is(FileProtocol.Kind.RESPONSE_NOT_FOUND));
            assertThat(results.get(2).getLocation(), endsWith("available"));
            assertThat(results.get(2).getKind(), is(FileProtocol.Kind.RESPONSE_DELETED));
            assertThat(results.get(3).getLocation(), endsWith("nothing3"));
            assertThat(results.get(3).getKind(), is(FileProtocol.Kind.RESPONSE_NOT_FOUND));

            assertThat(storage.getHeadCacheInfo(), is(nullValue()));
        } finally {
            storage.close();
        }
    }
View Full Code Here

                "EXAMPLE",
                Collections.singleton("COL"),
                "com.example.Model",
                123L);
        framework.deployLibrary(TestDataModel.class, "batchapps/tbatch/lib/jobflow-tflow.jar");
        CacheStorage storage = new CacheStorage(getConfiguration(), getTargetUri());
        try {
            storage.putPatchCacheInfo(info);
            ModelOutput<TestDataModel> output = create(storage, storage.getPatchContents("0"));
            try {
                TestDataModel model = new TestDataModel();
                model.systemId.set(100);
                model.value.set("Hello, world!");
                model.deleted.set(false);
                output.write(model);
            } finally {
                output.close();
            }

            execute(CacheBuildClient.SUBCOMMAND_CREATE);
            assertThat(storage.getHeadCacheInfo(), is(info));

            List<TestDataModel> results = collect(storage, storage.getHeadContents("*"));
            assertThat(results.size(), is(1));
            assertThat(results.get(0).systemId.get(), is(100L));
            assertThat(results.get(0).value.toString(), is("Hello, world!"));
        } finally {
            storage.close();
        }
    }
View Full Code Here

                "EXAMPLE",
                Collections.singleton("COL"),
                "com.example.Model",
                123L);
        framework.deployLibrary(TestDataModel.class, "batchapps/tbatch/lib/jobflow-tflow.jar");
        CacheStorage storage = new CacheStorage(getConfiguration(), getTargetUri());
        try {
            storage.putPatchCacheInfo(info);
            ModelOutput<TestDataModel> output = create(storage, storage.getPatchContents("0"));
            try {
                TestDataModel model = new TestDataModel();
                for (int i = 0; i < 100; i++) {
                    model.systemId.set(i);
                    model.deleted.set(i % 10 != 0);
                    output.write(model);
                }
            } finally {
                output.close();
            }

            execute(CacheBuildClient.SUBCOMMAND_CREATE);
            assertThat(storage.getHeadCacheInfo(), is(info));

            List<TestDataModel> results = collect(storage, storage.getHeadContents("*"));
            assertThat(results.size(), is(10));
            for (int i = 0; i < 10; i++) {
                assertThat(results.get(i).systemId.get(), is(i * 10L));
            }
        } finally {
            storage.close();
        }
    }
View Full Code Here

                "EXAMPLE",
                Collections.singleton("COL"),
                "com.example.Model",
                123L);
        framework.deployLibrary(TestDataModel.class, "batchapps/tbatch/lib/jobflow-tflow.jar");
        CacheStorage storage = new CacheStorage(getConfiguration(), getTargetUri());
        try {
            storage.putPatchCacheInfo(info);
            ModelOutput<TestDataModel> head = create(storage, storage.getHeadContents("0"));
            try {
                TestDataModel model = new TestDataModel();
                model.systemId.set(1);
                model.value.set("HEAD");
                model.deleted.set(false);
                head.write(model);

                model.systemId.set(2);
                model.value.set("HEAD");
                model.deleted.set(false);
                head.write(model);
            } finally {
                head.close();
            }
            ModelOutput<TestDataModel> patch = create(storage, storage.getPatchContents("0"));
            try {
                TestDataModel model = new TestDataModel();
                model.systemId.set(1);
                model.value.set("NEXT");
                model.deleted.set(false);
                patch.write(model);

                model.systemId.set(3);
                model.value.set("NEXT");
                model.deleted.set(false);
                patch.write(model);
            } finally {
                patch.close();
            }

            execute(CacheBuildClient.SUBCOMMAND_UPDATE);
            assertThat(storage.getHeadCacheInfo(), is(info));

            List<TestDataModel> results = collect(storage, storage.getHeadContents("*"));
            assertThat(results.size(), is(3));
            assertThat(results.get(0).systemId.get(), is(1L));
            assertThat(results.get(0).value.toString(), is("NEXT"));
            assertThat(results.get(1).systemId.get(), is(2L));
            assertThat(results.get(1).value.toString(), is("HEAD"));
            assertThat(results.get(2).systemId.get(), is(3L));
            assertThat(results.get(2).value.toString(), is("NEXT"));
        } finally {
            storage.close();
        }
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.thundergate.runtime.cache.CacheStorage

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.