text:
package pl.edu.icm.oxides.unicore;

import de.fzj.unicore.uas.client.StorageClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import pl.edu.icm.oxides.user.OxidesPortalGridSession;
import pl.edu.icm.oxides.user.UserResources;
import pl.edu.icm.unicore.spring.util.GridClientHelper;

import java.io.InputStream;

import static org.unigrids.services.atomic.types.ProtocolType.BFT;
import static org.unigrids.services.atomic.types.ProtocolType.RBYTEIO;

@Service
public class GridFileUploader {
    private final GridClientHelper clientHelper;

    @Autowired
    public GridFileUploader(GridClientHelper clientHelper) {
        this.clientHelper = clientHelper;
    }

    public String uploadFileToGrid(MultipartFile file, OxidesPortalGridSession oxidesPortalGridSession) {
        UserResources userResources = oxidesPortalGridSession.getResources();

        String fileName = file.getName();
        String originalFilename = file.getOriginalFilename();
        log.info(String.format("Storing file with name '%s' and original filename '%s'", fileName, originalFilename));

        String name = originalFilename;
        if (file.isEmpty()) {
            return "You failed to upload " + name + " because the file was empty.";
        }

        try {
            importFileToGrid(
                    userResources.getStorageClient(),
                    name,
                    file.getInputStream()
            );
            return "You successfully uploaded " + name + "!";
        } catch (Exception e) {
            return "You failed to upload " + name + " => " + e.getMessage();
        }
    }

    public void importFileToGrid(StorageClient storageClient, String filename, InputStream source) throws Exception {
        storageClient
                .getImport(filename, BFT, RBYTEIO)
                .writeAllData(source);
    }

    private Log log = LogFactory.getLog(GridFileUploader.class);
}


text:
""" Nodes, wrapping other groups of nodes or node chains

This package contains meta nodes,
which call other node chains or nodes for parameter optimization,
to skip some training phase or initialization,
or to combine the results.
"""

redpajama_set_name: RedPajamaGithub


text:
<?php

//Enable CoLabsSEO on these custom Post types
//$seo_post_types = array('post','page');
//define("SEOPOSTTYPES", serialize($seo_post_types));

//Global options setup
add_action('init','colabs_global_options');
function colabs_global_options(){
	// Populate CoLabsThemes option in array for use in theme
	global $colabs_options;
	$colabs_options = get_option('colabs_options');
}

add_action('admin_head','colabs_options');
if (!function_exists('colabs_options')) {
function colabs_options(){

// VARIABLES
$themename = "Photogram";
$manualurl = 'http://colorlabsproject.com';
$shortname = "photogram";

//More Options
$other_entries = array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");

$other_entries_10 = array("Select a number:","1","2","3","4","5","6","7","8","9","10");

$other_entries_4 = array("Select a number:","1","2","3","4");

$other_entries_5 = array("1","2","3","4","5");

$other_entries_65 = array("Select a number:","10","15","20","25","30","35","40","45","50","55","60","65");

// THIS IS THE DIFFERENT FIELDS
$options = array();

// General Settings
$options[] = array( "name" => __("General Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "general");

$options[] = array( "name" => __( "Use for blog title/logo", "colabsthemes" ),
					"desc" => __( "Select title or logo for your blog.", "colabsthemes" ),
					"id" => $shortname."_logotitle",
					"std" => "logo",
					"type" => "select2",
					"options" => array( "logo" => __( "Logo", "colabsthemes" ), "title" => __( "Title", "colabsthemes" ) ) );

$options[] = array( "name" => __("Custom Favicon","colabsthemes"),
					"desc" => __("Upload a 16x16px ico image that will represent your website's favicon. Favicon/bookmark icon will be shown at the left of your blog's address in visitor's internet browsers.","colabsthemes"),
					"id" => $shortname."_custom_favicon",
					"std" => get_template_directory_uri() . "/images/favicon.png",
					"type" => "upload");

$options[] = array( "name" => __("Header Custom Logo","colabsthemes"),
					"desc" => __("Upload a logo for your theme, or specify an image URL directly. Best image size in 219x48 px","colabsthemes"),
					"id" => $shortname."_logo",
					"std" => get_template_directory_uri() . "/images/logo.png",
					"type" => "upload");

$options[] = array( "name" => __("Show Content","colabsthemes"),
					"desc" => __("Show The Content in archive.","colabsthemes"),
					"id" => $shortname."_custom_excerpt",
					"std" => "false",
					"type" => "checkbox");

$options[] = array( "name" => "Disable Responsive",
					"desc" => "You can disable responsive module for your site.",
					"id" => $shortname."_disable_mobile",
					"std" => "false",
					"type" => "checkbox");

// Posts FrontPage Options
$options[] = array( "name" => __("FrontPage Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "home");

$options[] = array( "name" => __("FrontPage Title", "colabsthemes" ),
					"desc" => __("Entry Title Posts in here.", "colabsthemes" ),
					"id" => $shortname."_title",
					"std" => "Most Popular Photograph",
					"class" => "",
					"type" => "text");

$options[] = array( "name" => __( "Home Page Content", "colabsthemes" ),
					"desc" => __( "Select Post, Photographs, Pinterest, Instragram.", "colabsthemes" ),
					"id" => $shortname."_home",
					"std" => "Posts",
					"type" => "select2",
					"options" => array( "Posts" => __("Posts", "colabsthemes"), "Picasa" => __("Picasa", "colabsthemes"), "Photographs" => __("Photographs", "colabsthemes"), "Pinterest" => __("Pinterest", "colabsthemes"), "Dribbble" => __("Dribbble", "colabsthemes") ) );

// Picasa FrontPage Options
$options[] = array( "name" => __("Picasa Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "home");

$options[] = array( "name" => __("Picasa Username", "colabsthemes" ),
					"desc" => __("Entry Picasa Username in here.", "colabsthemes" ),
					"id" => $shortname."_username_picasa",
					"std" => "113539730014413629030",
					"type" => "text");

$options[] = array( "name" => __( "Count Picasa", "colabsthemes" ),
					"desc" => __( "Entry the limit for Picasa.", "colabsthemes" ),
					"id" => $shortname."_piccount_picasa",
					"std" => "10",
					"class" => "",
					"type" => "text");

// Pinterest FrontPage Options
$options[] = array( "name" => __("Pinterest Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "home");

$options[] = array( "name" => __("Pinterest Username", "colabsthemes" ),
					"desc" => __("Entry pinterest username in here.", "colabsthemes" ),
					"id" => $shortname."_username_pinterest",
					"class" => "",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Count Pinterest", "colabsthemes" ),
					"desc" => __( "Entry the limit for pinterest.", "colabsthemes" ),
					"id" => $shortname."_piccount_pinterest",
					"std" => "10",
					"class" => "",
					"type" => "text");

$options[] = array( "name" => __("Specific Board (optional):", "colabsthemes" ),
					"desc" => __("Enter the specific board for the pinterest", "colabsthemes" ),
					"id" => $shortname."_board_pinterest",
					"class" => "",
					"std" => "",
					"type" => "text");

// Dribbble FrontPage Options
$options[] = array( "name" => __("Dribbble Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "home");

$options[] = array( "name" => __("Dribbble Username", "colabsthemes" ),
					"desc" => __("Entry dribbble username in here.", "colabsthemes" ),
					"id" => $shortname."_username_dribbble",
					"class" => "",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Count Dribbble", "colabsthemes" ),
					"desc" => __( "Entry the limit for dribbble.", "colabsthemes" ),
					"id" => $shortname."_piccount_dribbble",
					"std" => "10",
					"class" => "",
					"type" => "text");

/*
/* //Social Settings	 */
$options[] = array( "name" => __("Social Networking","colabsthemes"),
					"icon" => "misc",
					"type" => "heading");

$options[] = array( "name" => __("Facebook","colabsthemes"),
					"desc" => __("Enter your Facebook profile URL","colabsthemes"),
					"id" => $shortname."_social_facebook",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __("Twitter","colabsthemes"),
					"desc" => __("Enter your Twitter URL","colabsthemes"),
					"id" => $shortname."_social_twitter",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Flickr URL", "colabsthemes" ),
					"desc" => __( "Enter your Flickr URL", "colabsthemes" ),
					"id" => $shortname."_social_flickr",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Picasa URL", "colabsthemes" ),
					"desc" => __( "Enter your Picasa account", "colabsthemes" ),
					"id" => $shortname."_social_picasa",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "WordPress URL", "colabsthemes" ),
					"desc" => __( "Enter your WordPress account", "colabsthemes" ),
					"id" => $shortname."_social_wordpress",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Google URL", "colabsthemes" ),
					"desc" => __( "Enter your Google URL", "colabsthemes" ),
					"id" => $shortname."_social_google",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "Vimeo URL", "colabsthemes" ),
					"desc" => __( "Enter your Vimeo URL", "colabsthemes" ),
					"id" => $shortname."_social_vimeo",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __( "LinkedIn URL", "colabsthemes" ),
					"desc" => __( "Enter your LinkedIn URL", "colabsthemes" ),
					"id" => $shortname."_social_linked",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __("Enable/Disable Social Share Button","colabsthemes" ),
					"desc" => __("Select which social share button you would like to enable.","colabsthemes" ),
					"id" => $shortname."_share",
					"std" => array("fblike","twitter","google_plusone"),
					"type" => "multicheck2",
                    "class" => "",
					"options" => array(
                                    "fblike" => "Facebook Like Button",
                                    "twitter" => "Twitter Share Button",
                                    "google_plusone" => "Google +1 Button",
									"pinterest" => "Pinterest",
									"linkedin" => "Linked In"
                                )
                    );

// Open Graph Settings
$options[] = array( "name" => __("Open Graph Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "graph");

$options[] = array( "name" => __("Open Graph","colabsthemes"),
					"desc" => __("Enable or disable Open Graph Meta tags.","colabsthemes"),
					"id" => $shortname."_og_enable",
					"type" => "select2",
                    "std" => "",
                    "class" => "collapsed",
					"options" => array("" => "Enable", "disable" => "Disable") );

$options[] = array( "name" => __("Site Name","colabsthemes"),
					"desc" => __("Open Graph Site Name ( og:site_name ).","colabsthemes"),
					"id" => $shortname."_og_sitename",
					"std" => "",
                    "class" => "hidden",
					"type" => "text");

$options[] = array( "name" => __("Admin","colabsthemes"),
					"desc" => __("Open Graph Admin ( fb:admins ).","colabsthemes"),
					"id" => $shortname."_og_admins",
					"std" => "",
                    "class" => "hidden",
					"type" => "text");

$options[] = array( "name" => __("Image","colabsthemes"),
					"desc" => __("You can put the url for your Open Graph Image ( og:image ).","colabsthemes"),
					"id" => $shortname."_og_img",
					"std" => "",
                    "class" => "hidden last",
					"type" => "text");

//Dynamic Images
$options[] = array( "name" => __("Thumbnail Settings","colabsthemes"),
					"type" => "heading",
					"icon" => "image");

$options[] = array( "name" => __("WordPress Featured Image","colabsthemes"),
					"desc" => __("Use WordPress Featured Image for post thumbnail.","colabsthemes"),
					"id" => $shortname."_post_image_support",
					"std" => "true",
					"class" => "collapsed",
					"type" => "checkbox");

$options[] = array( "name" => __("WordPress Featured Image - Dynamic Resize","colabsthemes"),
					"desc" => __("Resize post thumbnail dynamically using WordPress native functions (requires PHP 5.2+).","colabsthemes"),
					"id" => $shortname."_pis_resize",
					"std" => "true",
					"class" => "hidden",
					"type" => "checkbox");

$options[] = array( "name" => __("WordPress Featured Image - Hard Crop","colabsthemes"),
					"desc" => __("Original image will be cropped to match the target aspect ratio.","colabsthemes"),
					"id" => $shortname."_pis_hard_crop",
					"std" => "true",
					"class" => "hidden last",
					"type" => "checkbox");

$options[] = array( "name" => __("Automatic Thumbnail","colabsthemes"),
					"desc" => __("Generate post thumbnail from the first image uploaded in post (if there is no image specified through post custom field or WordPress Featured Image feature).","colabsthemes"),
					"id" => $shortname."_auto_img",
					"std" => "true",
					"type" => "checkbox");

$options[] = array( "name" => __("Thumbnail Image in RSS Feed","colabsthemes"),
					"desc" => __("Add post thumbnail to RSS feed article.","colabsthemes"),
					"id" => $shortname."_rss_thumb",
					"std" => "false",
					"type" => "checkbox");

$options[] = array( "name" => __("Thumbnail Image Dimensions","colabsthemes"),
					"desc" => __("Enter an integer value i.e. 250 for the desired size which will be used when dynamically creating the images.","colabsthemes"),
					"id" => $shortname."_image_dimensions",
					"std" => "",
					"type" => array(
									array(  'id' => $shortname. '_thumb_w',
											'type' => 'text',
											'std' => 100,
											'meta' => 'Width'),
									array(  'id' => $shortname. '_thumb_h',
											'type' => 'text',
											'std' => 100,
											'meta' => 'Height')
								  ));

$options[] = array( "name" => __("Custom Field Image","colabsthemes"),
					"desc" => __("Enter your custom field image name to change the default name (default name: image).","colabsthemes"),
					"id" => $shortname."_custom_field_image",
					"std" => "",
					"type" => "text");

// Analytics ID, RSS feed
$options[] = array( "name" => __("Analytics ID, RSS feed","colabsthemes"),
					"type" => "heading",
					"icon" => "statistics");

$options[] = array( "name" => __("Enable PressTrends Tracking","colabsthemes"),
					"desc" => __("PressTrends is a simple usage tracker that allows us to see how our customers are using our themes, so that we can help improve them for you. None of your personal data is sent to PressTrends.","colabsthemes"),
					"id" => $shortname."_pt_enable",
					"std" => "true",
					"type" => "checkbox");

$options[] = array( "name" => __("GoSquared Token","colabsthemes"),
					"desc" => __("You can use GoSquared real-time web analytics. Enter your GoSquared Token here (ex. GSN-893821-D).","colabsthemes"),
					"id" => $shortname."_gosquared_id",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __("Google Analytics","colabsthemes"),
					"desc" => __("Manage your website statistics with Google Analytics, put your Analytics Code here. ","colabsthemes"),
					"id" => $shortname."_google_analytics",
					"std" => "",
					"type" => "textarea");

$options[] = array( "name" => __("Feedburner ID","colabsthemes"),
					"desc" => __("Enter your Feedburner ID.","colabsthemes"),
					"id" => $shortname."_feedid",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __("Feedburner URL","colabsthemes"),
					"desc" => __("Feedburner URL. This will replace RSS feed link. Start with http://.","colabsthemes"),
					"id" => $shortname."_feedlinkurl",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => __("Feedburner Comments URL","colabsthemes"),
					"desc" => __("Feedburner URL. This will replace RSS comment feed link. Start with http://.","colabsthemes"),
					"id" => $shortname."_feedlinkcomments",
					"std" => "",
					"type" => "text");

/* //Contact Form */
$options[] = array( "name" => __("Contact Form","colabsthemes"),
					"type" => "heading",
					"icon" => "general");

$options[] = array( "name" => __("Destination Email Address","colabsthemes"),
					"desc" => __("All inquiries made by your visitors through the Contact Form page will be sent to this email address.","colabsthemes"),
					"id" => $shortname."_contactform_email",
					"std" => "",
					"type" => "text");

if ( get_option('colabs_template') != $options) update_option('colabs_template',$options);
if ( get_option('colabs_themename') != $themename) update_option('colabs_themename',$themename);
if ( get_option('colabs_shortname') != $shortname) update_option('colabs_shortname',$shortname);
if ( get_option('colabs_manual') != $manualurl) update_option('colabs_manual',$manualurl);

//PressTrends
$colabs_pt_auth = "3bkal5czl80s94uurt8ku5rj3riwbtjt7";
update_option('colabs_pt_auth',$colabs_pt_auth);

// CoLabs Metabox Options
// Start name with underscore to hide custom key from the user
$colabs_metaboxes = array();
$colabs_metabox_settings = array();
global $post;

    //Metabox Settings
    $colabs_metabox_settings['post'] = array(
                                'id' => 'colabsthemes-settings',
								'title' => 'ColorLabs' . __( ' Post Detail Settings', 'colabsthemes' ),
								'callback' => 'colabsthemes_metabox_create',
								'page' => 'post',
								'context' => 'normal',
								'priority' => 'high',
                                'callback_args' => ''
								);

if ( ( 'post' == get_post_type()) ) {

	$colabs_metaboxes[] = array (  "name"  => $shortname."_single_top",
					            "std"  => "Image",
					            "label" => "Item to Show",
					            "type" => "radio",
								"class" => "",
					            "desc" => "Choose Image/Embed Code to appear at the single top.",
								"options" => array(	"none" => "None",
													"single_image" => "Image",
													"single_video" => "Embed" ));
	$colabs_metaboxes[] = array (	"name" => "image",
								"label" => "Post Custom Image",
								"type" => "upload",
                                "class" => "single_image",
								"desc" => "Upload an image or enter an URL.");

	$colabs_metaboxes[] = array (  "name"  => $shortname."_embed",
					            "std"  => "",
					            "label" => "Video Embed Code",
					            "type" => "textarea",
                                "class" => "single_video",
					            "desc" => "Enter the video embed code for your video (YouTube, Vimeo or similar)");

}

if ( get_option('colabs_custom_template') != $colabs_metaboxes){
    update_option('colabs_custom_template',$colabs_metaboxes);
    }
if ( get_option('colabs_metabox_settings') != $colabs_metabox_settings){
    update_option('colabs_metabox_settings',$colabs_metabox_settings);
    }

}
}

?>


text:
package com.beiyelin.shop.modules.shop.entity;

import com.beiyelin.shop.common.persistence.DataEntity;
import com.google.common.collect.Maps;
import com.beiyelin.shop.common.config.Global;
import com.beiyelin.shop.modules.sys.entity.User;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @author Tony Wong
 */
public class CouponUser extends DataEntity<CouponUser> {

    private static final long serialVersionUID = 1L;

    private User user;
    private String hasUsed;
    private String couponId;
    private String name;
    private String desc;
    private Float price;
    private Date startDate;
    private Date endDate;
    private String type;
    private String typeDesc;
    private Integer durationDay;
    private String durationDayDesc;
    private Integer usedType;
    private String usedTypeDesc;

    public CouponUser() {
        super();
        this.setHasUsed(Global.NO);
    }

    public CouponUser(String id) {
        super();
        this.id = id;
        this.setHasUsed(Global.NO);
    }

    /**
     * 只转化当前字段, 方便给json用
     * @return
     */
    public Map<String, Object> toSimpleObj() {
        Map<String, Object> map = Maps.newHashMap();
        map.put("id", id);
        map.put("hasUsed", hasUsed);
        map.put("name", name);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        map.put("price", price);
        map.put("usedType", usedType);
        map.put("usedTypeDesc", usedTypeDesc);
        map.put("type", type);
        map.put("typeDesc", typeDesc);
        return map;
    }

    /**
     * 只转化当前字段, 方便给json用, 在前端float可能被解释为int,float,所以统一用string代替
     * @return
     */
    public Map<String, Object> toSimpleObjString() {
        Map<String, Object> map = toSimpleObj();
        DecimalFormat df = new DecimalFormat("0.00");
        map.put("price", df.format(price));
        return map;
    }

    /**
     * 转化CouponUser为普通对象,并且计算剩余的天数等
     */
    public Map<String, Object> toSimpleObjWithCal() {
        Map<String, Object> map = toSimpleObj();
        String oLeftTimeStr;
        long leftTime;
        Date nowDate = new Date();
        if (hasUsed.equals(Global.NO)) {
            if (endDate != null) {
                if (endDate.getTime() > nowDate.getTime()) {
                    leftTime = (endDate.getTime() - nowDate.getTime()) / (24 * 3600 * 1000) + 1;
                    oLeftTimeStr = "剩" + leftTime + "天";
                } else {
                    leftTime = 0;
                    oLeftTimeStr = "已过期";
                }
            } else {
                leftTime = -1; //永久有效
                oLeftTimeStr = "有效";
            }
        } else {
            leftTime = 0;
            oLeftTimeStr = "已使用";
        }

        String oStartDateStr = "";
        String oEndDateStr = "";
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        if (startDate != null) {
            oStartDateStr = df.format(startDate);
        }
        if (endDate != null) {
            oEndDateStr = df.format(endDate);
        }

        map.put("leftTime", leftTime);
        map.put("leftTimeStr", oLeftTimeStr);
        map.put("startDateStr", oStartDateStr);
        map.put("endDateStr", oEndDateStr);

        return map;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getHasUsed() {
        return hasUsed;
    }

    public void setHasUsed(String hasUsed) {
        this.hasUsed = hasUsed;
    }

    public String getCouponId() {
        return couponId;
    }

    public void setCouponId(String couponId) {
        this.couponId = couponId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeDesc() {
        return typeDesc;
    }

    public void setTypeDesc(String typeDesc) {
        this.typeDesc = typeDesc;
    }

    public Integer getDurationDay() {
        return durationDay;
    }

    public void setDurationDay(Integer durationDay) {
        this.durationDay = durationDay;
    }

    public String getDurationDayDesc() {
        return durationDayDesc;
    }

    public void setDurationDayDesc(String durationDayDesc) {
        this.durationDayDesc = durationDayDesc;
    }

    public Integer getUsedType() {
        return usedType;
    }

    public void setUsedType(Integer usedType) {
        this.usedType = usedType;
    }

    public String getUsedTypeDesc() {
        return usedTypeDesc;
    }

    public void setUsedTypeDesc(String usedTypeDesc) {
        this.usedTypeDesc = usedTypeDesc;
    }
}


text:
package org.apache.ignite.spi.discovery.tcp.ipfinder.zk;

import com.google.common.collect.Sets;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.curator.x.discovery.UriSpec;
import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter;
import org.codehaus.jackson.map.annotate.JsonRootName;

/**
 * This TCP Discovery IP Finder uses Apache ZooKeeper (ZK) to locate peer nodes when bootstrapping in order to join
 * the cluster. It uses the Apache Curator library to interact with ZooKeeper in a simple manner. Specifically,
 * it uses the {@link ServiceDiscovery} recipe, which makes use of ephemeral nodes in ZK to register services.
 *
 *

 * There are several ways to instantiate the TcpDiscoveryZookeeperIpFinder:
 *

 *
By providing an instance of {@link CuratorFramework} directly, in which case no ZK Connection String
 *     is required.

 *
By providing a ZK Connection String through {@link #setZkConnectionString(String)}, and optionally
 *     a {@link RetryPolicy} through the setter. If the latter is not provided, a default
 *     {@link ExponentialBackoffRetry} policy is used, with a base sleep time of 1000ms and 10 retries.

 *
By providing a ZK Connection String through system property {@link #PROP_ZK_CONNECTION_STRING}. If this
 *     property is set, it overrides the ZK Connection String passed in as a property, but it does not override
 *     the {@link CuratorFramework} if provided.

 *

 *
 * You may customise the base path for services, as well as the service name. By default {@link #BASE_PATH} and
 * {@link #SERVICE_NAME} are use respectively. You can also choose to enable or disable duplicate registrations. See
 * {@link #setAllowDuplicateRegistrations(boolean)} for more details.
 *
 * @see Apache ZooKeeper
 * @see Apache Curator
 *
 * @author Raul Kripalani
 */
public class TcpDiscoveryZookeeperIpFinder extends TcpDiscoveryIpFinderAdapter {

    /** System property name to provide the ZK Connection String. */
    public static final String PROP_ZK_CONNECTION_STRING = "IGNITE_ZK_CONNECTION_STRING";

    /** Default base path for service registrations. */
    private static final String BASE_PATH = "/services";

    /** Default service name for service registrations. */
    private static final String SERVICE_NAME = "ignite";

    /** Default URI Spec to use with the {@link ServiceDiscoveryBuilder}. */
    private static final UriSpec URI_SPEC = new UriSpec("{address}:{port}");

    /** Init guard. */
    @GridToStringExclude
    private final AtomicBoolean initGuard = new AtomicBoolean();

    /** Logger. */
    @LoggerResource
    private IgniteLogger log;

    /** The Curator framework in use, either injected or constructed by this component. */
    private CuratorFramework curator;

    /** The ZK Connection String if provided by the user. */
    private String zkConnectionString;

    /** Retry policy to use. */
    private RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 10);

    /** Base path to use, by default {#link #BASE_PATH}. */
    private String basePath = BASE_PATH;

    /** Service name to use, by default {#link #SERVICE_NAME}. */
    private String serviceName = SERVICE_NAME;

    /** Whether to allow or not duplicate registrations. See setter doc. */
    private boolean allowDuplicateRegistrations = false;

    /** The Service Discovery recipe. */
    private ServiceDiscovery<IgniteInstanceDetails> discovery;

    /** Map of the {#link ServiceInstance}s we have registered. */
    private Map<InetSocketAddress, ServiceInstance<IgniteInstanceDetails>> ourInstances = new ConcurrentHashMap<>();

    /** Constructor. */
    public TcpDiscoveryZookeeperIpFinder() {
        setShared(true);
    }

    /** Initializes this IP Finder by creating the appropriate Curator objects. */
    private void init() {
        if (!initGuard.compareAndSet(false, true))
            return;

        String sysPropZkConnString = System.getProperty(PROP_ZK_CONNECTION_STRING);

        if (sysPropZkConnString != null && sysPropZkConnString.trim().length() > 0)
            zkConnectionString = sysPropZkConnString;

        log.info("Initializing ZooKeeper IP Finder.");

        if (curator == null) {
            A.notNullOrEmpty(zkConnectionString, String.format("ZooKeeper URL (or system property %s) cannot be null " +
                "or empty if a CuratorFramework object is not provided explicitly", PROP_ZK_CONNECTION_STRING));
            curator = CuratorFrameworkFactory.newClient(zkConnectionString, retryPolicy);
        }

        if (curator.getState() != CuratorFrameworkState.STARTED)
            curator.start();

        discovery = ServiceDiscoveryBuilder.builder(IgniteInstanceDetails.class)
            .client(curator)
            .basePath(basePath)
            .serializer(new JsonInstanceSerializer<>(IgniteInstanceDetails.class))
            .build();
    }

    /** {@inheritDoc} */
    @Override public void onSpiContextDestroyed() {
        if (!initGuard.compareAndSet(true, false))
            return;

        log.info("Destroying ZooKeeper IP Finder.");

        super.onSpiContextDestroyed();

        if (curator != null)
            curator.close();

    }

    /** {@inheritDoc} */
    @Override public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException {
        init();

        if (log.isDebugEnabled())
            log.debug("Getting registered addresses from ZooKeeper IP Finder.");

        Collection<ServiceInstance<IgniteInstanceDetails>> serviceInstances;

        try {
            serviceInstances = discovery.queryForInstances(serviceName);
        } catch (Exception e) {
            log.warning("Error while getting registered addresses from ZooKeeper IP Finder.", e);
            return Collections.emptyList();
        }

        Set<InetSocketAddress> answer = new HashSet<>();

        for (ServiceInstance<IgniteInstanceDetails> si : serviceInstances)
            answer.add(new InetSocketAddress(si.getAddress(), si.getPort()));

        log.info("ZooKeeper IP Finder resolved addresses: " + answer);

        return answer;
    }

    /** {@inheritDoc} */
    @Override public void registerAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException {
        init();

        log.info("Registering addresses with ZooKeeper IP Finder: " + addrs);

        Set<InetSocketAddress> registrationsToIgnore = Sets.newHashSet();
        if (!allowDuplicateRegistrations) {
            try {
                for (ServiceInstance<IgniteInstanceDetails> sd : discovery.queryForInstances(serviceName))
                    registrationsToIgnore.add(new InetSocketAddress(sd.getAddress(), sd.getPort()));
            }
            catch (Exception e) {
                log.warning("Error while finding currently registered services to avoid duplicate registrations", e);
                throw new IgniteSpiException(e);
            }
        }

        for (InetSocketAddress addr : addrs) {
            if (registrationsToIgnore.contains(addr))
                continue;

            try {
                ServiceInstance<IgniteInstanceDetails> si = ServiceInstance.<IgniteInstanceDetails>builder()
                        .name(serviceName)
                        .uriSpec(URI_SPEC)
                        .address(addr.getAddress().getHostAddress())
                        .port(addr.getPort())
                        .build();

                ourInstances.put(addr, si);

                discovery.registerService(si);

            } catch (Exception e) {
                log.warning(String.format("Error while registering an address from ZooKeeper IP Finder " +
                    "[message=%s,addresses=%s]", e.getMessage(), addr), e);
            }
        }
    }

    /** {@inheritDoc} */
    @Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException {

        // if curator is not STARTED, we have nothing to unregister, because we are using ephemeral nodes,
        // which means that our addresses will only be registered in ZK as long as our connection is alive
        if (curator.getState() != CuratorFrameworkState.STARTED)
            return;

        log.info("Unregistering addresses with ZooKeeper IP Finder: " + addrs);

        for (InetSocketAddress addr : addrs) {
            ServiceInstance<IgniteInstanceDetails> si = ourInstances.get(addr);
            if (si == null) {
                log.warning("Asked to unregister address from ZooKeeper IP Finder, but no match was found in local " +
                        "instance map for: " + addrs);
                continue;
            }

            try {
                discovery.unregisterService(si);
            } catch (Exception e) {
                log.warning("Error while unregistering an address from ZooKeeper IP Finder: " + addr, e);
            }
        }
    }

    /**
     * @param curator A {@link CuratorFramework} instance to use. It can already be in <tt>STARTED</tt> state.
     */
    public void setCurator(CuratorFramework curator) {
        this.curator = curator;
    }

    /**
     * @return The ZooKeeper connection string, only if set explicitly. Else, it returns null.
     */
    public String getZkConnectionString() {
        return zkConnectionString;
    }

    /**
     * @param zkConnectionString ZooKeeper connection string in case a {@link CuratorFramework} is not being set explicitly.
     */
    public void setZkConnectionString(String zkConnectionString) {
        this.zkConnectionString = zkConnectionString;
    }

    /**
     * @return Retry policy in use if, and only if, it was set explicitly. Else, it returns null.
     */
    public RetryPolicy getRetryPolicy() {
        return retryPolicy;
    }

    /**
     * @param retryPolicy {@link RetryPolicy} to use in case a ZK Connection String is being injected, or if
     *                    using a system property.
     */
    public void setRetryPolicy(RetryPolicy retryPolicy) {
        this.retryPolicy = retryPolicy;
    }

    /**
     * @return Base path for service registration in ZK. Default value: {@link #BASE_PATH}.
     */
    public String getBasePath() {
        return basePath;
    }

    /**
     * @param basePath Base path for service registration in ZK. If not passed, {@link #BASE_PATH} will be used.
     */
    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    /**
     * @return Service name being used, in Curator terms. See {@link #setServiceName(String)} for more information.
     */
    public String getServiceName() {
        return serviceName;
    }

    /**
     * @param serviceName Service name to use, as defined by Curator's {#link ServiceDiscovery} recipe. In physical
     *                    ZK terms, it represents the node under {@link #basePath}, under which services will be
     *                    registered.
     */
    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    /**
     * * @return The value of this flag. See {@link #setAllowDuplicateRegistrations(boolean)} for more details.
     */
    public boolean isAllowDuplicateRegistrations() {
        return allowDuplicateRegistrations;
    }

    /**
     * @param allowDuplicateRegistrations Whether to register each node only once, or if duplicate registrations
     *                                    are allowed. Nodes will attempt to register themselves, plus those they
     *                                    know about. By default, duplicate registrations are not allowed, but you
     *                                    might want to set this property to <tt>true</tt> if you have multiple
     *                                    network interfaces or if you are facing troubles.
     */
    public void setAllowDuplicateRegistrations(boolean allowDuplicateRegistrations) {
        this.allowDuplicateRegistrations = allowDuplicateRegistrations;
    }

    /**
     * Empty DTO for storing service instances details. Currently acting as a placeholder because Curator requires
     * a payload type when registering and discovering nodes. May be enhanced in the future with further information
     * to assist discovery.
     *
     * @author Raul Kripalani
     */
    @JsonRootName("ignite_instance_details")
    private class IgniteInstanceDetails {

    }

}


text:
layout: organization
category: local

title: Huntington Hospital - Children/Pediatric Wing
impact_area: Health
keywords:
location_services:
location_offices:
website: http://www.huntingtonhospital.com/Main/Pediatrics.aspx

description:
mission: |
  Founded by concerned citizens and shaped by community health- care needs, Huntington Hospital is a full-service, not-for-profit, community hospital, serving Huntington Township and surrounding communities. The Hospital is a member of the North Shore-Long Island Jewish Health System and shares in the System's vision of being a preeminent healthcare delivery system in the tradition of excellence, and the embodiment of community values and human dignity. Our primary mission is to provide a full range of inpatient, outpatient, and specialized healthcare services within an environment nurtured by respect and safety. We are committed to giving our patients high-quality and technologically advanced care by competent professionals in order to maintain and improve the health and well-being of the community.

cash_grants:
grants:
service_opp:
services:

learn:
cont_relationship:

salutation:
first_name:
last_name:
title_contact_person:

city: Huntington
state: NY
address: |
  270 Park Avenue
  Huntington NY 11743
lat: 40.880096
lng: -73.417599
phone: 631-351-2000
ext:
fax:
email:
preferred_contact:
contact_person_intro:
---


text:
struct CMEAObject
{
	TProgressDialog *progress;
	structure *ct;

	double percent;
	int structures;
	double gamma;
	int window;

    CFormView *parent;
	char *ctoutfile;
	char *savefile;

};

// CMEADialog dialog

class CMEADialog : public CFormView
{
	DECLARE_DYNCREATE(CMEADialog)

public:
	CMEADialog(CWnd* pParent = NULL);   // standard constructor
	LRESULT DoneFolding(WPARAM wParam, LPARAM lParam);
	CFoldDoc *GetFoldDocument();
	void OnUpdate(CView*, LPARAM, CObject*);
	virtual ~CMEADialog();
	#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

// Dialog Data
	enum { IDD = IDD_MEA };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedPartition();

	afx_msg void OnBnClickedCtbutton();

	afx_msg void OnBnClickedStart();

	CString m_SEQUENCE;

	CString m_CT;

private:
	bool started;
	CMEAObject meaobject;//Use a stochastic object to pass information to a seperate thread
	double m_percent;
	int m_structures;
	int m_window;
	double m_gamma;
	TProgressDialog *progress;
};


text:
namespace flutter {
namespace testing {

/// Mock for the |WindowWin32| base class.
class MockTextInputManagerWin32 : public TextInputManagerWin32 {
 public:
  MockTextInputManagerWin32();
  virtual ~MockTextInputManagerWin32();

  // Prevent copying.
  MockTextInputManagerWin32(MockTextInputManagerWin32 const&) = delete;
  MockTextInputManagerWin32& operator=(MockTextInputManagerWin32 const&) =
      delete;

  MOCK_CONST_METHOD0(GetComposingString, std::optional<std::u16string>());
  MOCK_CONST_METHOD0(GetResultString, std::optional<std::u16string>());
  MOCK_CONST_METHOD0(GetComposingCursorPosition, long());
};

}  // namespace testing
}  // namespace flutter

#endif  // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_MOCK_TEXT_INPUT_MANAGER_WIN32_H_