Search in sources :

Example 6 with Marker

use of org.slf4j.Marker in project cassandra-mesos-deprecated by mesosphere.

the class CassandraScheduler method resourceOffers.

@Override
public void resourceOffers(final SchedulerDriver driver, final List<Offer> offers) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("> resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }
    for (final Offer offer : offers) {
        final Marker marker = MarkerFactory.getMarker("offerId:" + offer.getId().getValue() + ",hostname:" + offer.getHostname());
        final boolean offerUsed = evaluateOffer(driver, marker, offer);
        if (!offerUsed) {
            LOGGER.trace(marker, "Declining Offer: {}", offer.getId().getValue());
            driver.declineOffer(offer.getId());
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("< resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }
}
Also used : Marker(org.slf4j.Marker)

Example 7 with Marker

use of org.slf4j.Marker in project cassandra-mesos-deprecated by mesosphere.

the class CassandraExecutor method launchTask.

@Override
public void launchTask(final ExecutorDriver driver, final TaskInfo task) {
    final Marker taskIdMarker = MarkerFactory.getMarker(task.getTaskId().getValue());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(taskIdMarker, "> launchTask(driver : {}, task : {})", driver, protoToString(task));
    }
    try {
        driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_STARTING));
        final ByteString data = task.getData();
        final TaskDetails taskDetails = TaskDetails.parseFrom(data);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(taskIdMarker, "received taskDetails: {}", protoToString(taskDetails));
        }
        handleProcessNoLongerAlive(driver);
        switch(taskDetails.getType()) {
            case EXECUTOR_METADATA:
                final ExecutorMetadataTask executorMetadataTask = taskDetails.getExecutorMetadataTask();
                final ExecutorMetadata slaveMetadata = collectSlaveMetadata(executorMetadataTask);
                final SlaveStatusDetails details = SlaveStatusDetails.newBuilder().setStatusDetailsType(SlaveStatusDetails.StatusDetailsType.EXECUTOR_METADATA).setExecutorMetadata(slaveMetadata).build();
                driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_RUNNING, details));
                break;
            case CASSANDRA_SERVER_RUN:
                safeShutdown();
                try {
                    final CassandraServerRunTask cassandraServerRunTask = taskDetails.getCassandraServerRunTask();
                    process = objectFactory.launchCassandraNodeTask(taskIdMarker, cassandraServerRunTask);
                    try {
                        Thread.sleep(500);
                        final int exitCode = process.exitValue();
                        process = null;
                        LOGGER.error(taskIdMarker, "Cassandra daemon process exited early with code " + exitCode + " - see logs for details");
                        driver.sendStatusUpdate(ExecutorUtils.slaveErrorDetails(task, "Cassandra daemon process exited early with code " + exitCode + " see logs for details", "-", SlaveErrorDetails.ErrorType.PROCESS_EXITED));
                    } catch (InterruptedException | IllegalThreadStateException e) {
                    // that's what we want (ITSE)
                    }
                    serverTask = task;
                    jmxConnect = objectFactory.newJmxConnect(cassandraServerRunTask.getJmx());
                    startCheckingHealth(driver, jmxConnect, cassandraServerRunTask.getHealthCheckIntervalSeconds());
                    driver.sendStatusUpdate(taskStatus(serverTask, TaskState.TASK_RUNNING, SlaveStatusDetails.newBuilder().setStatusDetailsType(SlaveStatusDetails.StatusDetailsType.CASSANDRA_SERVER_RUN).setCassandraServerRunMetadata(CassandraServerRunMetadata.newBuilder().setPid(process.getPid())).build()));
                } catch (final LaunchNodeException e) {
                    LOGGER.error(taskIdMarker, "Failed to start Cassandra daemon", e);
                    driver.sendStatusUpdate(ExecutorUtils.slaveErrorDetails(task, "Failed to start Cassandra daemon", e.toString(), SlaveErrorDetails.ErrorType.PROCESS_NOT_RUNNING));
                }
                break;
            case UPDATE_CONFIG:
                if (serverTask == null) {
                    driver.sendStatusUpdate(ExecutorUtils.slaveErrorDetails(task, "Failed to update config - no Cassandra daemon running", "-", SlaveErrorDetails.ErrorType.PROCESS_NOT_RUNNING));
                } else {
                    driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_RUNNING));
                    final TaskDetails serverTaskDetails = TaskDetails.parseFrom(serverTask.getData());
                    try {
                        objectFactory.updateCassandraServerConfig(taskIdMarker, serverTaskDetails.getCassandraServerRunTask(), taskDetails.getUpdateConfigTask());
                    } catch (ConfigChangeException e) {
                        driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_FAILED));
                    }
                    driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_FINISHED));
                }
                break;
            case NODE_JOB:
                startJob(driver, task, taskDetails);
                break;
        }
    } catch (final InvalidProtocolBufferException e) {
        final String msg = "Error deserializing task data to type: " + TaskDetails.class.getName();
        LOGGER.error(taskIdMarker, msg, e);
        final TaskStatus taskStatus = ExecutorUtils.slaveErrorDetails(task, msg, null, SlaveErrorDetails.ErrorType.PROTOCOL_VIOLATION);
        driver.sendStatusUpdate(taskStatus);
    } catch (final Exception e) {
        final String msg = "Error starting task due to exception.";
        LOGGER.error(taskIdMarker, msg, e);
        final TaskStatus taskStatus = ExecutorUtils.slaveErrorDetails(task, msg, e.getMessage() != null ? e.getMessage() : "-", SlaveErrorDetails.ErrorType.TASK_START_FAILURE);
        driver.sendStatusUpdate(taskStatus);
    }
    LOGGER.debug(taskIdMarker, "< launchTask(driver : {}, task : {})", driver, protoToString(task));
}
Also used : ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Marker(org.slf4j.Marker) ProtoUtils.protoToString(io.mesosphere.mesos.util.ProtoUtils.protoToString) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 8 with Marker

use of org.slf4j.Marker in project cassandra-mesos-deprecated by mesosphere.

the class CassandraClusterStateTest method allResourcesAvailableBeforeLaunchingExecutor.

@Test
public void allResourcesAvailableBeforeLaunchingExecutor() throws Exception {
    cleanState();
    final String role = "*";
    final Protos.Offer offer = Protos.Offer.newBuilder().setFrameworkId(frameworkId).setHostname("localhost").setId(Protos.OfferID.newBuilder().setValue(randomID())).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave_1")).addResources(cpu(0.1, role)).addResources(mem(0.1, role)).addResources(disk(0.1, role)).addResources(ports(Lists.<Long>emptyList(), role)).build();
    final Marker marker = MarkerFactory.getMarker("offerId:" + offer.getId().getValue() + ",hostname:" + offer.getHostname());
    assertThat(cluster._getTasksForOffer(marker, offer)).isNull();
}
Also used : Protos(org.apache.mesos.Protos) CassandraFrameworkProtos(io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos) Marker(org.slf4j.Marker) Test(org.junit.Test)

Example 9 with Marker

use of org.slf4j.Marker in project flink by apache.

the class YarnTestBase method ensureNoProhibitedStringInLogFiles.

/**
	 * This method checks the written TaskManager and JobManager log files
	 * for exceptions.
	 *
	 * WARN: Please make sure the tool doesn't find old logfiles from previous test runs.
	 * So always run "mvn clean" before running the tests here.
	 *
	 */
public static void ensureNoProhibitedStringInLogFiles(final String[] prohibited, final String[] whitelisted) {
    File cwd = new File("target/" + yarnConfiguration.get(TEST_CLUSTER_NAME_KEY));
    Assert.assertTrue("Expecting directory " + cwd.getAbsolutePath() + " to exist", cwd.exists());
    Assert.assertTrue("Expecting directory " + cwd.getAbsolutePath() + " to be a directory", cwd.isDirectory());
    File foundFile = findFile(cwd.getAbsolutePath(), new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            // scan each file for prohibited strings.
            File f = new File(dir.getAbsolutePath() + "/" + name);
            try {
                Scanner scanner = new Scanner(f);
                while (scanner.hasNextLine()) {
                    final String lineFromFile = scanner.nextLine();
                    for (String aProhibited : prohibited) {
                        if (lineFromFile.contains(aProhibited)) {
                            boolean whitelistedFound = false;
                            for (String white : whitelisted) {
                                if (lineFromFile.contains(white)) {
                                    whitelistedFound = true;
                                    break;
                                }
                            }
                            if (!whitelistedFound) {
                                // logging in FATAL to see the actual message in TRAVIS tests.
                                Marker fatal = MarkerFactory.getMarker("FATAL");
                                LOG.error(fatal, "Prohibited String '{}' in line '{}'", aProhibited, lineFromFile);
                                return true;
                            }
                        }
                    }
                }
            } catch (FileNotFoundException e) {
                LOG.warn("Unable to locate file: " + e.getMessage() + " file: " + f.getAbsolutePath());
            }
            return false;
        }
    });
    if (foundFile != null) {
        Scanner scanner = null;
        try {
            scanner = new Scanner(foundFile);
        } catch (FileNotFoundException e) {
            Assert.fail("Unable to locate file: " + e.getMessage() + " file: " + foundFile.getAbsolutePath());
        }
        LOG.warn("Found a file with a prohibited string. Printing contents:");
        while (scanner.hasNextLine()) {
            LOG.warn("LINE: " + scanner.nextLine());
        }
        Assert.fail("Found a file " + foundFile + " with a prohibited string: " + Arrays.toString(prohibited));
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Scanner(java.util.Scanner) FileNotFoundException(java.io.FileNotFoundException) Marker(org.slf4j.Marker) File(java.io.File)

Example 10 with Marker

use of org.slf4j.Marker in project midpoint by Evolveum.

the class Slf4jConnectorLogger method log.

@Override
public void log(Class<?> clazz, String method, Level level, String message, Throwable ex) {
    Trace LOGGER = TraceManager.getTrace(clazz);
    //Mark all messages from ICF as ICF
    Marker m = MarkerFactory.getMarker("ICF");
    // ERROR -> error
    if (Level.OK.equals(level)) {
        if (null == ex) {
            LOGGER.trace(m, "method: {} msg:{}", method, message);
        } else {
            LOGGER.trace(m, "method: {} msg:{}", new Object[] { method, message }, ex);
        }
    } else if (Level.INFO.equals(level)) {
        if (null == ex) {
            LOGGER.debug(m, "method: {} msg:{}", method, message);
        } else {
            LOGGER.debug(m, "method: {} msg:{}", new Object[] { method, message }, ex);
        }
    } else if (Level.WARN.equals(level)) {
        if (null == ex) {
            LOGGER.warn(m, "method: {} msg:{}", method, message);
        } else {
            LOGGER.warn(m, "method: {} msg:{}", new Object[] { method, message }, ex);
        }
    } else if (Level.ERROR.equals(level)) {
        if (null == ex) {
            LOGGER.error(m, "method: {} msg:{}", method, message);
        } else {
            LOGGER.error(m, "method: {} msg:{}", new Object[] { method, message }, ex);
        }
    }
}
Also used : Trace(com.evolveum.midpoint.util.logging.Trace) Marker(org.slf4j.Marker)

Aggregations

Marker (org.slf4j.Marker)12 ByteString (com.google.protobuf.ByteString)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 Test (org.junit.Test)2 Trace (com.evolveum.midpoint.util.logging.Trace)1 CassandraFrameworkProtos (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos)1 ProtoUtils.protoToString (io.mesosphere.mesos.util.ProtoUtils.protoToString)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FilenameFilter (java.io.FilenameFilter)1 Scanner (java.util.Scanner)1 Protos (org.apache.mesos.Protos)1