Programming

This is a simple tutorial that shows how easily (and without depending on third party APIs) you can write a simple scheduler in Java. Java comes with build in capability for scheduling using java.util.Timer class and java.util.TimerTask ...
This is a simple tutorial that shows how easily (and without depending on third party APIs) you can write a simple scheduler in Java. Java comes with build in capability for scheduling using java.util.Timer class and java.util.TimerTask class. package com.kushal.tools; /** * @Author Kushal Paudyal * Scheduling a task using Java in-house scheduler * Created : 2011/04/28 * Last Modified: 2011/04/28 */ import java.util.Timer; import java.util.TimerTask; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Date; public final class SchedulerUsingJavaUtil extends TimerTask { private final static long FREQUENCY_ONE_DAY = 1000 * 60 * 60 * 24; private final static int ONE_DAY = 0; private final static int HOUR_AM = 10; private final static int MINUTES = 52; /** * Construct and use a TimerTask and Timer. */ public static void main(String[] arguments) { TimerTask scheduledTask = new SchedulerUsingJavaUtil(); Timer timer = new Timer(); /** * Schedules the specified task for repeated fixed-rate execution, * beginning at the specified time. Subsequent executions take place at * approximately regular intervals, separated by the specified period. * In fixed-rate execution, each execution is scheduled relative to the * scheduled execution time of the initial execution. If an execution is * delayed for any reason (such as garbage collection or other * background activity), two or more executions will occur in rapid * succession to "catch up." In the long run, the frequency of execution * will be exactly the reciprocal of the specified period (assuming the * system clock underlying Object.wait(long) is accurate). * * Fixed-rate execution is appropriate for recurring activities that are * sensitive to absolute time, such as ringing a chime every hour on the * hour, or running scheduled maintenance every day at a particular * time. It is also appropriate for recurring activities where the total * time to perform a fixed number of executions is important, such as a * countdown timer that ticks once every second for ten seconds. * Finally, fixed-rate execution is appropriate for scheduling multiple * repeating timer tasks that must remain synchronized with respect to * one another. * * * Parameters: * task - task to be scheduled. * firstTime - First time at which task is to be executed. * period - time in milliseconds between successive task executions. * Throws: IllegalArgumentException - if * time.getTime() is negative. IllegalStateException - if task was * already scheduled or cancelled, timer was cancelled, or timer thread * terminated. */ timer.scheduleAtFixedRate(scheduledTask, getFirstRunTime(),FREQUENCY_ONE_DAY); } /** * Implements TimerTask's abstract run() method. */ public void run() { System.out.println("Doing some task..."+new Date()); } /** * Create a time when scheduler needs to run first */ private static Date getFirstRunTime() { /** * Get Today's Calendar */ Calendar tomorrow = new GregorianCalendar(); /** * Add one day to get tomorrow's calendar */ tomorrow.add(Calendar.DATE, ONE_DAY); /** * Set the scheduled time for tomorrow. */ Calendar firstRunTime = new GregorianCalendar( tomorrow.get(Calendar.YEAR), tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE), HOUR_AM, MINUTES); return firstRunTime.getTime(); } } Originally posted 2011-05-17 20:53:56.
about 1 hour ago
2013/05/25 -- Jeremiah Jordan
2013/05/25 -- Jeremiah Jordan
about 2 hours ago
2013/05/25 -- Peter Lin
2013/05/25 -- Peter Lin
about 2 hours ago
App42 platform gives you the power to host your custom server side code in our cloud. Below are the listed features and advantages for the same.
App42 platform gives you the power to host your custom server side code in our cloud. Below are the listed features and advantages for the same.
about 2 hours ago
2013/05/25 -- Edward Capriolo
2013/05/25 -- Edward Capriolo
about 3 hours ago
The highlight of this system is a clear separation of the cube computation engine and the query serving engine of this OLAP system. Another newness is the use of a key value store, Voldemort, to fetch the results of queries. Contrary to ...
The highlight of this system is a clear separation of the cube computation engine and the query serving engine of this OLAP system. Another newness is the use of a key value store, Voldemort, to fetch the results of queries. Contrary to conventional designs where the cube computation engine and the query serving infra are coupled tightly, Avatara chooses to separate these two aspects. The offline batch engine is based on Hadoop. A set of MapReduce jobs transform the data into cubes. These cubes are then bulk loaded into the key value store for fast online access. The batch processing pipeline consists of three phases: preprocessing, projections and joins and cubification. Each of these phases is a collection of MapReduce jobs and carried out executed sequentially. After data is preprocessed in the first phase a star schema is modeled in the second phase. The engine projects and joins the fields from the fact and dimension tables and writes the output to a temp location. The third phase is when the cubification happens. This phase generates a number of small cubes as MOLAP blobs (multidimensional array) containing dimensions and measures. The storage format is optimized such that the query engine can retrieve this data in a single disk fetch. When clients issue queries it is intercepted by the online query engine component. The engine reads data from the key value store. The query engine models a SQL like syntax and supports operations such as select, where and group by along with some math operations. Since the system is built to keep query response times very low it disallows joins from being performed online. The discussion section (3.4) of the paper best summarizes the design trade offs. Worth inlining verbatim – Avatara provides ?exibility in terms of where cube materialization can happen: operations such as sum, average, order, or limit can be performed of?ine or online. With more of?ine aggregation, online queries will be faster, but naturally less ?exible. For example, after a developer speci?es the granularity of a time dimension to be at the “week” level in the of?ine phase, future online aggregations can only happen at equal or coarser levels such as “weeks” or “months”. For WVMP, partial materialization happens of?ine to roll up pro?le visits into a weekly aggregation level; the remaining materialization happens online because the cubes are small. This also enables us to introduce new query patterns by selecting a different set of dimensions without recomputing any cubes. Link to the paper.
about 4 hours ago
This past week 6 new mashups were added to our mashup directory and 6 different APIs were used to build them. Some of the newer or less frequently seen APIs include PriceSpin and Primal. The most often used APIs this week are foursquare...
This past week 6 new mashups were added to our mashup directory and 6 different APIs were used to build them. Some of the newer or less frequently seen APIs include PriceSpin and Primal. The most often used APIs this week are foursquare, Google Maps and PriceSpin. And the most commonly used types of APIs were Mapping (1 APIs, 2 mashups), Music (1 APIs, 1 mashups) and Shopping (1 APIs, 1 mashups). The list below shows which APIs were used by which mashups: Echo Nest used in Bluth Radio foursquare used in HangoutLater Google Maps used in Companies Near Me, GeoGuessr Instagram used in Worldcam PriceSpin used in ShopSmart Brazil Primal used in ShopSmart Brazil Mashups of the day:And each day there is one mashup selected to be Mashup of the Day. Here are last week’s winners: Bluth Radio Companies Near Me GeoGuessr HangoutLater ShopSmart Brazil Worldcam Sponsored by
about 4 hours ago
While fine art is a subjective field, graphic design is more formulaic in its fundamentals. An effective design should make people feel a certain way and take a certain action. In this article I’d like to share Gravity Switch’s web desig...
While fine art is a subjective field, graphic design is more formulaic in its fundamentals. An effective design should make people feel a certain way and take a certain action. In this article I’d like to share Gravity Switch’s web design principles and our thinking behind them.
about 5 hours ago
At pennies per virtual machine-hour, the economics of cloud computing are both compelling and daunting to replicate. Whether you are building your own cloud infrastructure, building a public cloud or choosing a cloud service, there are k...
At pennies per virtual machine-hour, the economics of cloud computing are both compelling and daunting to replicate. Whether you are building your own cloud infrastructure, building a public cloud or choosing a cloud service, there are key strategy and technology decisions that make the difference between success and failure. In his General Session at the 12th International Cloud Expo, Jason Waxman, VP in the Intel Architecture Group and general manager of the Cloud Platforms Group within Intel's Datacenter and Connected Systems Group, will share industry best practices for deploying cloud infrastructure that maximize the benefits of cloud economics, agility and interoperability. Learn how Intel is working with industry leaders to deliver open, secure and efficient cloud computing based on optimized compute, networking, storage and software technology and what are key tools and resources to help you achieve your cloud computing goals.read more
about 5 hours ago
You're getting pitched every day from your legacy enterprise software and hardware vendors about "cloud." They're doing an amazing job of convincing your CIO and CTO about what cloud is and how you should use it. The reality is...
You're getting pitched every day from your legacy enterprise software and hardware vendors about "cloud." They're doing an amazing job of convincing your CIO and CTO about what cloud is and how you should use it. The reality is they're defending their shrinking market share and keeping you on the legacy treadmill for as long as they can by selling you solutions that aren't "cloud." In her session at the 12th International Cloud Expo, Niki Acosta, Cloud Evangelista for Rackspace, will talk through the five dirty little secrets your legacy IT vendors won't tell you about cloud. Attendees will leave with an understanding of how you should really be thinking about building enterprise apps for the cloud while embracing the fundamental shift away from legacy IT.read more
about 5 hours ago