Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License
*
* Copyright 2015 Tim Boudreau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.mastfrog.blurt;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import static com.mastfrog.blurt.Blurt.BLURT_AUTOSTART;
import static com.mastfrog.blurt.Blurt.BLURT_ENABLED;
import static com.mastfrog.blurt.Blurt.BLURT_HEARTBEAT;
import static com.mastfrog.blurt.Blurt.BLURT_HEARTBEAT_INTERVAL_MILLIS;
import static com.mastfrog.blurt.Blurt.BLURT_LOOPBACK_ONLY;
import static com.mastfrog.blurt.Blurt.BLURT_RECEIVE;
import static com.mastfrog.blurt.Blurt.BLURT_SEND;
import static com.mastfrog.blurt.Blurt.BLURT_UDP_HOST;
import static com.mastfrog.blurt.Blurt.BLURT_UDP_IPV6;
import static com.mastfrog.blurt.Blurt.BLURT_UDP_NETWORK_INTERFACE;
import static com.mastfrog.blurt.Blurt.BLURT_UDP_PORT;
import static com.mastfrog.blurt.Blurt.BLURT_UDP_THREAD_COUNT;
import static com.mastfrog.blurt.Blurt.DEFAULT_HEARTBEAT_INTERVAL;
import static com.mastfrog.blurt.BlurtUDP.DEFAULT_IPV6_UDP_HOST;
import static com.mastfrog.blurt.BlurtUDP.DEFAULT_UDP_HOST;
import static com.mastfrog.blurt.BlurtUDP.DEFAULT_UDP_PORT;
import static com.mastfrog.blurt.BlurtUDP.logger;
import com.mastfrog.cluster.ApplicationInfo;
import com.mastfrog.giulius.annotations.Defaults;
import com.mastfrog.settings.Settings;
import com.mastfrog.shutdown.hooks.ShutdownHookRegistry;
import com.mastfrog.util.preconditions.Checks;
import com.mastfrog.util.collections.CollectionUtils;
import java.io.IOException;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.ProtocolFamily;
import java.net.SocketException;
import java.net.StandardProtocolFamily;
import java.nio.channels.ClosedChannelException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Timer;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* A way to blurt UDP packets into the ether. The idea is to simply pass in
* strings or objects, and the system-wide blurt instance will fire-and-forget
* them into the either. Then another application on the same network can pick
* the packets up and turn them into whatever it wants (a log, an activity
* monitor, statistics, you name it).
*
* Each blurt packet contains a timestamp and two identifying GUIDs: An
* "installation guid" (stored in ~/.appname), which is consistent across runs,
* and a "process guid" which is a unique ID of a specific process.
*
* IPv4 and IPv6 are supported. If you're using IPv4, packets may be truncated
* if they are longer than 512 bytes; if you want to blurt large stuff, use
* IPv6.
*
* @author Tim Boudreau
*/
//@Defaults(value = {BLURT_UDP_HOST + "=224.0.0.1",
// BLURT_UDP_PORT + "=41234",
// BLURT_UDP_THREAD_COUNT + "=2",
// BLURT_UDP_IPV6 + "=false",
// BLURT_ENABLED + "=true",
// BLURT_SEND + "=true",
// BLURT_RECEIVE + "=true"})
@Defaults(value = {BLURT_UDP_HOST + "=ff02::1",
BLURT_UDP_PORT + "=" + DEFAULT_UDP_PORT,
BLURT_UDP_THREAD_COUNT + "=6",
BLURT_UDP_IPV6 + "=true",
BLURT_ENABLED + "=true",
BLURT_SEND + "=true",
BLURT_RECEIVE + "=true"})
@Singleton
class BlurtUDP implements Blurt, BlurtControl {
static TypeReference MAP_TYPE = new TypeReference