Search in sources :

Example 1 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class DefaultBlockWorker method commitBlock.

@Override
public void commitBlock(long sessionId, long blockId) throws BlockAlreadyExistsException, BlockDoesNotExistException, InvalidWorkerStateException, IOException, WorkerOutOfSpaceException {
    // TODO(binfan): find a better way to handle retry logic
    try {
        mBlockStore.commitBlock(sessionId, blockId);
    } catch (BlockAlreadyExistsException e) {
        LOG.debug("Block {} has been in block store, this could be a retry due to master-side RPC " + "failure, therefore ignore the exception", blockId, e);
    }
    // TODO(calvin): Reconsider how to do this without heavy locking.
    // Block successfully committed, update master with new block metadata
    Long lockId = mBlockStore.lockBlock(sessionId, blockId);
    try {
        BlockMeta meta = mBlockStore.getBlockMeta(sessionId, blockId, lockId);
        BlockStoreLocation loc = meta.getBlockLocation();
        Long length = meta.getBlockSize();
        BlockStoreMeta storeMeta = mBlockStore.getBlockStoreMeta();
        Long bytesUsedOnTier = storeMeta.getUsedBytesOnTiers().get(loc.tierAlias());
        mBlockMasterClient.commitBlock(mWorkerId.get(), bytesUsedOnTier, loc.tierAlias(), blockId, length);
    } catch (AlluxioTException | IOException | ConnectionFailedException e) {
        throw new IOException(ExceptionMessage.FAILED_COMMIT_BLOCK_TO_MASTER.getMessage(blockId), e);
    } finally {
        mBlockStore.unlockBlock(lockId);
    }
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) BlockAlreadyExistsException(alluxio.exception.BlockAlreadyExistsException) IOException(java.io.IOException) BlockMeta(alluxio.worker.block.meta.BlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) ConnectionFailedException(alluxio.exception.ConnectionFailedException)

Example 2 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class JobWorker method start.

@Override
public void start(WorkerNetAddress address) throws IOException {
    super.start(address);
    // Start serving metrics system, this will not block
    MetricsSystem.startSinks(ServerConfiguration.getString(PropertyKey.METRICS_CONF_FILE));
    try {
        JobWorkerIdRegistry.registerWorker(mJobMasterClient, address);
    } catch (ConnectionFailedException e) {
        LOG.error("Failed to connect to job master", e);
        throw Throwables.propagate(e);
    }
    mTaskExecutorManager = new TaskExecutorManager(ServerConfiguration.getInt(PropertyKey.JOB_WORKER_THREADPOOL_SIZE), address);
    mCommandHandlingService = getExecutorService().submit(new HeartbeatThread(HeartbeatContext.JOB_WORKER_COMMAND_HANDLING, new CommandHandlingExecutor(mJobServerContext, mTaskExecutorManager, mJobMasterClient, address), (int) ServerConfiguration.getMs(PropertyKey.JOB_MASTER_WORKER_HEARTBEAT_INTERVAL), ServerConfiguration.global(), ServerUserState.global()));
}
Also used : TaskExecutorManager(alluxio.worker.job.task.TaskExecutorManager) HeartbeatThread(alluxio.heartbeat.HeartbeatThread) CommandHandlingExecutor(alluxio.worker.job.command.CommandHandlingExecutor) ConnectionFailedException(alluxio.exception.ConnectionFailedException)

Example 3 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class ServiceSocketBindIntegrationTest method connectDifferentAddress.

@Test
public void connectDifferentAddress() throws Exception {
    startCluster("");
    // Connect to Master RPC service on loopback, while Master is listening on local hostname.
    InetSocketAddress masterRpcAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getMaster().getRpcLocalPort());
    mBlockMasterClient = BlockMasterClient.Factory.create(masterRpcAddr);
    try {
        mBlockMasterClient.connect();
        Assert.fail("Client should not have successfully connected to master RPC service.");
    } catch (ConnectionFailedException e) {
    // This is expected, since Master RPC service is NOT listening on loopback.
    }
    // Connect to Worker RPC service on loopback, while Worker is listening on local hostname.
    try {
        mBlockWorkerClient = FileSystemContext.INSTANCE.createBlockWorkerClient(mLocalAlluxioCluster.getWorkerAddress());
        mBlockMasterClient.connect();
        Assert.fail("Client should not have successfully connected to Worker RPC service.");
    } catch (Exception e) {
    // This is expected, since Work RPC service is NOT listening on loopback.
    } finally {
        mBlockWorkerClient.close();
    }
    // connect Worker data service on loopback, while Worker is listening on local hostname.
    InetSocketAddress workerDataAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getWorker().getDataLocalPort());
    try {
        mWorkerDataService = SocketChannel.open(workerDataAddr);
        Assert.assertTrue(mWorkerDataService.isConnected());
        Assert.fail("Client should not have successfully connected to Worker RPC service.");
    } catch (IOException e) {
    // This is expected, since Worker data service is NOT listening on loopback.
    }
    // connect Master Web service on loopback, while Master is listening on local hostname.
    try {
        mMasterWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getMaster().getInternalMaster().getWebAddress().getPort() + "/home").openConnection();
        Assert.assertEquals(200, mMasterWebService.getResponseCode());
        Assert.fail("Client should not have successfully connected to Master Web service.");
    } catch (IOException e) {
    // This is expected, since Master Web service is NOT listening on loopback.
    } finally {
        Assert.assertNotNull(mMasterWebService);
        mMasterWebService.disconnect();
    }
    // connect Worker Web service on loopback, while Worker is listening on local hostname.
    try {
        mWorkerWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getWorker().getWebLocalPort() + "/home").openConnection();
        Assert.assertEquals(200, mWorkerWebService.getResponseCode());
        Assert.fail("Client should not have successfully connected to Worker Web service.");
    } catch (IOException e) {
    // This is expected, since Worker Web service is NOT listening on loopback.
    } finally {
        mWorkerWebService.disconnect();
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) ConnectionFailedException(alluxio.exception.ConnectionFailedException) ConnectionFailedException(alluxio.exception.ConnectionFailedException) IOException(java.io.IOException) URL(java.net.URL) Test(org.junit.Test)

Example 4 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class AbstractFileSystem method initializeInternal.

/**
   * Initializes the default contexts if the master address specified in the URI is different
   * from the default one.
   *
   * @param uri the uri
   * @param conf the hadoop conf
   * @throws IOException if it fails to initialize
   */
void initializeInternal(URI uri, org.apache.hadoop.conf.Configuration conf) throws IOException {
    // Load Alluxio configuration if any and merge to the one in Alluxio file system. These
    // modifications to ClientContext are global, affecting all Alluxio clients in this JVM.
    // We assume here that all clients use the same configuration.
    ConfUtils.mergeHadoopConfiguration(conf);
    Configuration.set(PropertyKey.ZOOKEEPER_ENABLED, isZookeeperMode());
    if (!Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) {
        Configuration.set(PropertyKey.MASTER_HOSTNAME, uri.getHost());
        Configuration.set(PropertyKey.MASTER_RPC_PORT, uri.getPort());
    }
    // These must be reset to pick up the change to the master address.
    // TODO(andrew): We should reset key value system in this situation - see ALLUXIO-1706.
    LineageContext.INSTANCE.reset();
    FileSystemContext.INSTANCE.reset();
    // Try to connect to master, if it fails, the provided uri is invalid.
    FileSystemMasterClient client = FileSystemContext.INSTANCE.acquireMasterClient();
    try {
        client.connect();
    // Connected, initialize.
    } catch (ConnectionFailedException | IOException e) {
        LOG.error("Failed to connect to the provided master address {}: {}.", uri.toString(), e.toString());
        throw new IOException(e);
    } finally {
        FileSystemContext.INSTANCE.releaseMasterClient(client);
    }
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) IOException(java.io.IOException) ConnectionFailedException(alluxio.exception.ConnectionFailedException)

Example 5 with ConnectionFailedException

use of alluxio.exception.ConnectionFailedException in project alluxio by Alluxio.

the class AlluxioFrameworkIntegrationTest method testMesosDeploy.

private void testMesosDeploy(Map<PropertyKey, String> properties) throws Exception {
    StringBuilder alluxioJavaOpts = new StringBuilder(System.getProperty("ALLUXIO_JAVA_OPTS", ""));
    for (Entry<PropertyKey, String> entry : properties.entrySet()) {
        alluxioJavaOpts.append(String.format(" -D%s=%s", entry.getKey().toString(), entry.getValue()));
    }
    Map<String, String> env = ImmutableMap.of("ALLUXIO_JAVA_OPTS", alluxioJavaOpts.toString());
    try {
        startAlluxioFramework(env);
        LOG.info("Launched Alluxio cluster, waiting for worker to register with master");
        String masterHostName = NetworkAddressUtils.getLocalHostName();
        int masterPort = Configuration.getInt(PropertyKey.MASTER_RPC_PORT);
        InetSocketAddress masterAddress = new InetSocketAddress(masterHostName, masterPort);
        try (final BlockMasterClient client = BlockMasterClient.Factory.create(masterAddress)) {
            CommonUtils.waitFor("Alluxio worker to register with master", new Function<Void, Boolean>() {

                @Override
                public Boolean apply(Void input) {
                    try {
                        try {
                            return !client.getWorkerInfoList().isEmpty();
                        } catch (ConnectionFailedException e) {
                            // block master isn't up yet, keep waiting
                            return false;
                        }
                    } catch (Exception e) {
                        throw Throwables.propagate(e);
                    }
                }
            }, WaitForOptions.defaults().setTimeout(15 * Constants.MINUTE_MS));
        }
        LOG.info("Worker registered");
        basicAlluxioTests();
    } finally {
        stopAlluxioFramework();
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ConnectionFailedException(alluxio.exception.ConnectionFailedException) BlockMasterClient(alluxio.client.block.BlockMasterClient) ConnectionFailedException(alluxio.exception.ConnectionFailedException) PropertyKey(alluxio.PropertyKey)

Aggregations

ConnectionFailedException (alluxio.exception.ConnectionFailedException)6 IOException (java.io.IOException)4 InetSocketAddress (java.net.InetSocketAddress)2 PropertyKey (alluxio.PropertyKey)1 BlockMasterClient (alluxio.client.block.BlockMasterClient)1 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)1 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)1 Command (alluxio.grpc.Command)1 HeartbeatThread (alluxio.heartbeat.HeartbeatThread)1 AlluxioTException (alluxio.thrift.AlluxioTException)1 BlockMeta (alluxio.worker.block.meta.BlockMeta)1 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)1 CommandHandlingExecutor (alluxio.worker.job.command.CommandHandlingExecutor)1 TaskExecutorManager (alluxio.worker.job.task.TaskExecutorManager)1 URL (java.net.URL)1 Test (org.junit.Test)1