org.apache.flink.configuration.BlobServerOptions Java Examples

The following examples show how to use org.apache.flink.configuration.BlobServerOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MiniDispatcherTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setupClass() throws IOException {
	jobGraph = new JobGraph();

	archivedExecutionGraph = new ArchivedExecutionGraphBuilder()
		.setJobID(jobGraph.getJobID())
		.setState(JobStatus.FINISHED)
		.build();

	rpcService = new TestingRpcService();
	configuration = new Configuration();

	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(configuration, new VoidBlobStore());
}
 
Example #2
Source File: BlobsCleanupITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
	blobBaseDir = TEMPORARY_FOLDER.newFolder();

	Configuration cfg = new Configuration();
	cfg.setString(BlobServerOptions.STORAGE_DIRECTORY, blobBaseDir.getAbsolutePath());
	cfg.setString(ConfigConstants.RESTART_STRATEGY, "fixeddelay");
	cfg.setInteger(ConfigConstants.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 1);
	// BLOBs are deleted from BlobCache between 1s and 2s after last reference
	// -> the BlobCache may still have the BLOB or not (let's test both cases randomly)
	cfg.setLong(BlobServerOptions.CLEANUP_INTERVAL, 1L);

	configuration = new UnmodifiableConfiguration(cfg);

	miniClusterResource = new MiniClusterResource(new MiniClusterResourceConfiguration.Builder()
		.setNumberSlotsPerTaskManager(2)
		.setNumberTaskManagers(1)
		.setConfiguration(configuration)
		.build());

	miniClusterResource.before();
}
 
Example #3
Source File: HDFSTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that with {@link HighAvailabilityMode#ZOOKEEPER} distributed JARs are recoverable from any
 * participating BlobServer when talking to the {@link org.apache.flink.runtime.blob.BlobServer} directly.
 */
@Test
public void testBlobServerRecovery() throws Exception {
	org.apache.flink.configuration.Configuration
		config = new org.apache.flink.configuration.Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, hdfsURI);

	BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

	try {
		BlobServerRecoveryTest.testBlobServerRecovery(config, blobStoreService);
	} finally {
		blobStoreService.closeAndCleanupAllData();
	}
}
 
Example #4
Source File: TransientBlobCache.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new BLOB cache.
 *
 * @param blobClientConfig
 * 		global configuration
 * @param serverAddress
 * 		address of the {@link BlobServer} to use for fetching files from or {@code null} if none yet
 * @throws IOException
 * 		thrown if the (local or distributed) file storage cannot be created or is not usable
 */
public TransientBlobCache(
		final Configuration blobClientConfig,
		@Nullable final InetSocketAddress serverAddress) throws IOException {

	super(blobClientConfig, new VoidBlobStore(), LoggerFactory.getLogger(TransientBlobCache.class), serverAddress
	);

	// Initializing the clean up task
	this.cleanupTimer = new Timer(true);

	this.cleanupInterval = blobClientConfig.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
	this.cleanupTimer
		.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
			storageDir, log), cleanupInterval, cleanupInterval);
}
 
Example #5
Source File: BlobCacheRetriesTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * A test where the connection fails too often and eventually fails the GET request
 * (with high availability set, job-related blob).
 */
@Test
public void testBlobForJobFetchWithTooManyFailuresHa() throws IOException {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.getRoot().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testBlobFetchWithTooManyFailures(config, blobStoreService, new JobID(), PERMANENT_BLOB);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #6
Source File: BlobCachePutTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private void testTransientBlobCacheGetStorageLocationConcurrent(
		@Nullable final JobID jobId) throws Exception {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	try (BlobServer server = new BlobServer(config, new VoidBlobStore());
		final TransientBlobCache cache = new TransientBlobCache(
			config, new InetSocketAddress("localhost", server.getPort()))) {

		server.start();

		BlobKey key = new TransientBlobKey();
		CheckedThread[] threads = new CheckedThread[] {
			new TransientBlobCacheGetStorageLocation(cache, jobId, key),
			new TransientBlobCacheGetStorageLocation(cache, jobId, key),
			new TransientBlobCacheGetStorageLocation(cache, jobId, key)
		};
		checkedThreadSimpleTest(threads);
	}
}
 
Example #7
Source File: BlobCacheRetriesTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * A test where the connection fails twice and then the get operation succeeds
 * (with high availability set, job-related job).
 */
@Test
public void testBlobFetchRetriesHa() throws IOException {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.newFolder().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testBlobFetchRetries(config, blobStoreService, new JobID(), PERMANENT_BLOB);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #8
Source File: BlobCacheCorruptionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the GET operation fails when the downloaded file (from {@link BlobServer} or HA store)
 * is corrupt, i.e. its content's hash does not match the {@link BlobKey}'s hash.
 *
 * @param jobId
 * 		job ID or <tt>null</tt> if job-unrelated
 * @param blobType
 * 		whether the BLOB should become permanent or transient
 * @param corruptOnHAStore
 * 		whether the file should be corrupt in the HA store (<tt>true</tt>, required
 * 		<tt>highAvailability</tt> to be set) or on the {@link BlobServer}'s local store
 * 		(<tt>false</tt>)
 */
private void testGetFailsFromCorruptFile(final JobID jobId, BlobKey.BlobType blobType,
		boolean corruptOnHAStore) throws IOException {

	final Configuration config = new Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testGetFailsFromCorruptFile(jobId, blobType, corruptOnHAStore, config,
			blobStoreService, exception);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #9
Source File: HDFSTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that with {@link HighAvailabilityMode#ZOOKEEPER} distributed corrupted JARs are
 * recognised during the download via a BLOB cache.
 */
@Test
public void testBlobCacheCorruptedFile() throws Exception {
	org.apache.flink.configuration.Configuration
		config = new org.apache.flink.configuration.Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, hdfsURI);

	BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

	try {
		BlobCacheCorruptionTest
			.testGetFailsFromCorruptFile(new JobID(), config, blobStoreService, exception);
	} finally {
		blobStoreService.closeAndCleanupAllData();
	}
}
 
Example #10
Source File: BlobCacheRetriesTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * A test where the connection fails too often and eventually fails the GET request
 * (with high availability set, job-related blob).
 */
@Test
public void testBlobForJobFetchWithTooManyFailuresHa() throws IOException {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.getRoot().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testBlobFetchWithTooManyFailures(config, blobStoreService, new JobID(), PERMANENT_BLOB);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #11
Source File: ExecutionGraphDeploymentWithBlobServerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void setupBlobServer() throws IOException {
	Configuration config = new Configuration();
	// always offload the serialized job and task information
	config.setInteger(BlobServerOptions.OFFLOAD_MINSIZE, 0);
	blobServer = Mockito.spy(new BlobServer(config, new VoidBlobStore()));
	blobWriter = blobServer;
	blobCache = blobServer;

	seenHashes.clear();

	// verify that we do not upload the same content more than once
	doAnswer(
		invocation -> {
			PermanentBlobKey key = (PermanentBlobKey) invocation.callRealMethod();

			assertTrue(seenHashes.add(key.getHash()));

			return key;
		}
	).when(blobServer).putPermanent(any(JobID.class), Matchers.<byte[]>any());

	blobServer.start();
}
 
Example #12
Source File: BlobServerCorruptionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the GET operation fails when the downloaded file (from {@link BlobServer} or HA store)
 * is corrupt, i.e. its content's hash does not match the {@link BlobKey}'s hash.
 */
@Test
public void testGetFailsFromCorruptFile() throws IOException {

	final Configuration config = new Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testGetFailsFromCorruptFile(config, blobStoreService, exception);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #13
Source File: BlobServerPutTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private void testServerContentAddressableGetStorageLocationConcurrent(
		@Nullable final JobID jobId) throws Exception {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	try (BlobServer server = new BlobServer(config, new VoidBlobStore())) {

		server.start();

		BlobKey key1 = new TransientBlobKey();
		BlobKey key2 = new PermanentBlobKey();
		CheckedThread[] threads = new CheckedThread[] {
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key2),
			new ContentAddressableGetStorageLocation(server, jobId, key2),
			new ContentAddressableGetStorageLocation(server, jobId, key2)
		};
		checkedThreadSimpleTest(threads);
	}
}
 
Example #14
Source File: BlobServerPutTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void testServerContentAddressableGetStorageLocationConcurrent(
		@Nullable final JobID jobId) throws Exception {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	try (BlobServer server = new BlobServer(config, new VoidBlobStore())) {

		server.start();

		BlobKey key1 = new TransientBlobKey();
		BlobKey key2 = new PermanentBlobKey();
		CheckedThread[] threads = new CheckedThread[] {
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key1),
			new ContentAddressableGetStorageLocation(server, jobId, key2),
			new ContentAddressableGetStorageLocation(server, jobId, key2),
			new ContentAddressableGetStorageLocation(server, jobId, key2)
		};
		checkedThreadSimpleTest(threads);
	}
}
 
Example #15
Source File: TransientBlobCache.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new BLOB cache.
 *
 * @param blobClientConfig
 * 		global configuration
 * @param serverAddress
 * 		address of the {@link BlobServer} to use for fetching files from or {@code null} if none yet
 * @throws IOException
 * 		thrown if the (local or distributed) file storage cannot be created or is not usable
 */
public TransientBlobCache(
		final Configuration blobClientConfig,
		@Nullable final InetSocketAddress serverAddress) throws IOException {

	super(blobClientConfig, new VoidBlobStore(), LoggerFactory.getLogger(TransientBlobCache.class), serverAddress
	);

	// Initializing the clean up task
	this.cleanupTimer = new Timer(true);

	this.cleanupInterval = blobClientConfig.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
	this.cleanupTimer
		.schedule(new TransientBlobCleanupTask(blobExpiryTimes, readWriteLock.writeLock(),
			storageDir, log), cleanupInterval, cleanupInterval);
}
 
Example #16
Source File: BlobsCleanupITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
	blobBaseDir = TEMPORARY_FOLDER.newFolder();

	Configuration cfg = new Configuration();
	cfg.setString(BlobServerOptions.STORAGE_DIRECTORY, blobBaseDir.getAbsolutePath());
	cfg.setString(ConfigConstants.RESTART_STRATEGY, "fixeddelay");
	cfg.setInteger(ConfigConstants.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 1);
	// BLOBs are deleted from BlobCache between 1s and 2s after last reference
	// -> the BlobCache may still have the BLOB or not (let's test both cases randomly)
	cfg.setLong(BlobServerOptions.CLEANUP_INTERVAL, 1L);

	configuration = new UnmodifiableConfiguration(cfg);

	miniClusterResource = new MiniClusterResource(new MiniClusterResourceConfiguration.Builder()
		.setNumberSlotsPerTaskManager(2)
		.setNumberTaskManagers(1)
		.setConfiguration(configuration)
		.build());

	miniClusterResource.before();
}
 
Example #17
Source File: BlobCacheRecoveryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that with {@link HighAvailabilityMode#ZOOKEEPER} distributed JARs are recoverable from any
 * participating BlobServer.
 */
@Test
public void testBlobCacheRecovery() throws Exception {
	Configuration config = new Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testBlobCacheRecovery(config, blobStoreService);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #18
Source File: BlobCachePutTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void testTransientBlobCacheGetStorageLocationConcurrent(
		@Nullable final JobID jobId) throws Exception {
	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	try (BlobServer server = new BlobServer(config, new VoidBlobStore());
		final TransientBlobCache cache = new TransientBlobCache(
			config, new InetSocketAddress("localhost", server.getPort()))) {

		server.start();

		BlobKey key = new TransientBlobKey();
		CheckedThread[] threads = new CheckedThread[] {
			new TransientBlobCacheGetStorageLocation(cache, jobId, key),
			new TransientBlobCacheGetStorageLocation(cache, jobId, key),
			new TransientBlobCacheGetStorageLocation(cache, jobId, key)
		};
		checkedThreadSimpleTest(threads);
	}
}
 
Example #19
Source File: BlobServerRecoveryTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that with {@link HighAvailabilityMode#ZOOKEEPER} distributed JARs are recoverable from any
 * participating BlobServer.
 */
@Test
public void testBlobServerRecovery() throws Exception {
	Configuration config = new Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getPath());

	BlobStoreService blobStoreService = null;

	try {
		blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

		testBlobServerRecovery(config, blobStoreService);
	} finally {
		if (blobStoreService != null) {
			blobStoreService.closeAndCleanupAllData();
		}
	}
}
 
Example #20
Source File: ExecutionGraphDeploymentWithBlobServerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Before
public void setupBlobServer() throws IOException {
	Configuration config = new Configuration();
	// always offload the serialized job and task information
	config.setInteger(BlobServerOptions.OFFLOAD_MINSIZE, 0);
	blobServer = Mockito.spy(new BlobServer(config, new VoidBlobStore()));
	blobWriter = blobServer;
	blobCache = blobServer;

	seenHashes.clear();

	// verify that we do not upload the same content more than once
	doAnswer(
		invocation -> {
			PermanentBlobKey key = (PermanentBlobKey) invocation.callRealMethod();

			assertTrue(seenHashes.add(key.getHash()));

			return key;
		}
	).when(blobServer).putPermanent(any(JobID.class), Matchers.<byte[]>any());

	blobServer.start();
}
 
Example #21
Source File: HDFSTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that with {@link HighAvailabilityMode#ZOOKEEPER} distributed corrupted JARs are
 * recognised during the download via a {@link org.apache.flink.runtime.blob.BlobServer}.
 */
@Test
public void testBlobServerCorruptedFile() throws Exception {
	org.apache.flink.configuration.Configuration
		config = new org.apache.flink.configuration.Configuration();
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH, hdfsURI);

	BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(config);

	try {
		BlobServerCorruptionTest.testGetFailsFromCorruptFile(config, blobStoreService, exception);
	} finally {
		blobStoreService.closeAndCleanupAllData();
	}
}
 
Example #22
Source File: ExecutionGraphDeploymentWithBlobCacheTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void setupBlobServer() throws IOException {
	Configuration config = new Configuration();
	// always offload the serialized job and task information
	config.setInteger(BlobServerOptions.OFFLOAD_MINSIZE, 0);
	blobServer = new BlobServer(config, new VoidBlobStore());
	blobServer.start();
	blobWriter = blobServer;

	InetSocketAddress serverAddress = new InetSocketAddress("localhost", blobServer.getPort());
	blobCache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
}
 
Example #23
Source File: BlobUtilsNonWritableTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test(expected = IOException.class)
public void testExceptionOnCreateStorageDirectoryFailure() throws IOException {
	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		new File(blobUtilsTestDirectory, CANNOT_CREATE_THIS).getAbsolutePath());
	// Should throw an Exception
	BlobUtils.initLocalStorageDirectory(config);
}
 
Example #24
Source File: BlobCachePutTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Uploads a byte array to a server which cannot create any files via the {@link
 * BlobCacheService}. File transfers should fail.
 *
 * @param jobId
 * 		job id
 * @param blobType
 * 		whether the BLOB should become permanent or transient
 */
private void testPutBufferFails(@Nullable final JobID jobId, BlobKey.BlobType blobType)
		throws IOException {
	assumeTrue(!OperatingSystem.isWindows()); //setWritable doesn't work on Windows.

	final Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	File tempFileDir = null;
	try (
		BlobServer server = new BlobServer(config, new VoidBlobStore());
		BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
		)) {

		server.start();

		// make sure the blob server cannot create any files in its storage dir
		tempFileDir = server.createTemporaryFilename().getParentFile().getParentFile();
		assertTrue(tempFileDir.setExecutable(true, false));
		assertTrue(tempFileDir.setReadable(true, false));
		assertTrue(tempFileDir.setWritable(false, false));

		byte[] data = new byte[2000000];
		rnd.nextBytes(data);

		// upload the file to the server via the cache
		exception.expect(IOException.class);
		exception.expectMessage("PUT operation failed: ");

		put(cache, jobId, data, blobType);

	} finally {
		// set writable again to make sure we can remove the directory
		if (tempFileDir != null) {
			//noinspection ResultOfMethodCallIgnored
			tempFileDir.setWritable(true, false);
		}
	}
}
 
Example #25
Source File: BlobServerResource.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void before() throws Throwable {
	temporaryFolder.create();

	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(config, new VoidBlobStore());
	blobServer.start();
}
 
Example #26
Source File: BlobCacheSuccessTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * BlobCache is configured in HA mode but the cache itself cannot access the
 * file system and thus needs to download BLOBs from the BlobServer. Using job-related BLOBs.
 */
@Test
public void testBlobForJobCacheHaFallback() throws IOException {
	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.newFolder().getPath());

	uploadFileGetTest(config, new JobID(), false, false, PERMANENT_BLOB);
}
 
Example #27
Source File: BlobCacheSuccessTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * BlobCache is configured in HA mode and the cache can download files from
 * the file system directly and does not need to download BLOBs from the
 * BlobServer which is shut down after the BLOB upload. Using job-related BLOBs.
 */
@Test
public void testBlobForJobCacheHa2() throws IOException {
	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.newFolder().getPath());
	uploadFileGetTest(config, new JobID(), false, true, PERMANENT_BLOB);
}
 
Example #28
Source File: BlobCacheSuccessTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * BlobCache is configured in HA mode and the cache can download files from
 * the file system directly and does not need to download BLOBs from the
 * BlobServer which remains active after the BLOB upload. Using job-related BLOBs.
 */
@Test
public void testBlobForJobCacheHa() throws IOException {
	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());
	config.setString(HighAvailabilityOptions.HA_MODE, "ZOOKEEPER");
	config.setString(HighAvailabilityOptions.HA_STORAGE_PATH,
		temporaryFolder.newFolder().getPath());

	uploadFileGetTest(config, new JobID(), true, true, PERMANENT_BLOB);
}
 
Example #29
Source File: BlobCacheSuccessTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * BlobCache with no HA, job-related BLOBS. BLOBs need to be downloaded form a working
 * BlobServer.
 */
@Test
public void testBlobForJobCache() throws IOException {
	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());

	uploadFileGetTest(config, new JobID(), false, false, TRANSIENT_BLOB);
}
 
Example #30
Source File: BlobServerResource.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected void before() throws Throwable {
	temporaryFolder.create();

	Configuration config = new Configuration();
	config.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	blobServer = new BlobServer(config, new VoidBlobStore());
	blobServer.start();
}