All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.scattersphere.job.example.Clock Maven / Gradle / Ivy

The newest version!
/*
 * Scattersphere
 * Copyright 2014-2015, Scattersphere Project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.scattersphere.job.example;

import net.scattersphere.job.AbstractJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * This is a simple clock test job.  It returns the current time in milliseconds, and current nanotime.
 *
 * Created by kenji on 11/26/14.
 */
public class Clock extends AbstractJob {

    private final Logger LOG = LoggerFactory.getLogger(Clock.class);

    public Clock() {
        LOG.debug("Clock job instantiated.");
    }

    @Override
    public String getDescription() {
        return "Retrieves server time at time of request.";
    }

    public void run()  {
        writeToStream(("Current Server Time: " + (new Date())).getBytes());
        writeToStream(("Milliseconds: " + System.currentTimeMillis()).getBytes());
        writeToStream(("Nanoseconds: " + System.nanoTime()).getBytes());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy