text:
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <openssl/md5.h>
#include <getopt.h>
#include <glib.h>

/* Use this macros if libhashfile library is installed on your system */
// #include <libhashfile.h>

/* Use this macros if libhashfile library is NOT installed on your system */
#include "data.h"
#include "libhashfile.h"

#define MAXLINE	4096

struct chunk_item {
    int size;
    int fid;
    int sid;
    int rc;
    int64_t fsize;
    char hash[20];
    char minhash[20];
    char suffix[8];
};

static int segment_size = 0;
static int max_segment_size = 0;
static int min_segment_size = 0;
static int wl_threshold = 1;

static GHashTable* chunkset = NULL;
static int file_count = 0;
static int segment_count = 0;
static int dup_chunks = 0;
static int collisions = 0;
static int detected_collisions = 0;
static int chunks_read_back = 0;
static char minhash[20];
static char suffix[8];
static int hashlen = 6;

static gboolean hash_equal(gpointer a, gpointer b){
    return !memcmp(a, b, hashlen);
}

static gboolean minhash_equal(gpointer a, gpointer b){
    return !memcmp(a, b, 20);
}

static void print_chunk_hash(uint64_t chunk_count, const uint8_t *hash,
        int hash_size_in_bytes)
{
    int j;

    printf("Chunk %06"PRIu64 ": ", chunk_count);

    printf("%.2hhx", hash[0]);
    for (j = 1; j < hash_size_in_bytes; j++)
        printf(":%.2hhx", hash[j]);
    printf("\n");
}

/* two chunks with this hash have different chunk size */
/* "18:06:bd:7a:61:11" */
char col[] = {0x18,0x6,0xbd,0x7a,0x61,0x11};

static char* parse_file_name(char *path){
    int i = strlen(path) - 1;
    while(i>=0 && path[i]!='\\' && path[i]!='/')
        i--;
    return &path[i+1];
}

static void check_curfile(GHashTable* curfile){

    GHashTableIter iter;
    gpointer key, value;
    g_hash_table_iter_init(&iter, curfile);

    while(g_hash_table_iter_next(&iter, &key, &value)){
        struct chunk_item* chunk = value;
        struct chunk_item* target = g_hash_table_lookup(chunkset, key);
        if(target){
            if(memcmp(target->hash, chunk->hash, 20)!=0){
                fprintf(stderr, "+Find a collision between %s <-> %s! Try to detect it!\n", target->suffix, suffix);
                fprintf(stderr, "+Details: MinHash = %s, Size %lld <-> %lld\n",
                        memcmp(target->minhash, chunk->minhash, 20) == 0?"True":"False",
                        target->fsize, chunk->fsize);
                collisions++;
            }else{
                dup_chunks++;
            }

            int read_back = 0;
            if(memcmp(target->minhash, minhash, 20) != 0){
                read_back = 1;
            }
            if(read_back){
                chunks_read_back++;
                if(memcmp(target->hash, chunk->hash, 20)!=0){
                    fprintf(stderr, "-Collision Detected!\n");
                    detected_collisions++;
                }
            }
            target->rc++;
        }else{
            chunk->fid = file_count;
            memcpy(chunk->minhash, minhash, 20);
            memcpy(chunk->suffix, suffix, 8);
            g_hash_table_iter_steal(&iter);
            g_hash_table_insert(chunkset, chunk->hash, chunk);
        }

    }
}

static void check_cursegment(GHashTable* cursegment, int enable_wl){

    GHashTableIter iter;
    gpointer key, value;

    GHashTable *whitelist = g_hash_table_new_full(g_int_hash, g_int_equal, free, NULL);

    g_hash_table_iter_init(&iter, cursegment);
    while(g_hash_table_iter_next(&iter, &key, &value)){
        struct chunk_item* chunk = value;
        struct chunk_item* target = g_hash_table_lookup(chunkset, key);
        if(target){
            int *sc = g_hash_table_lookup(whitelist, &target->sid);
            if(!sc){
                sc = malloc(sizeof(int)*2);
                sc[0] = target->sid;
                sc[1] = 0;
                g_hash_table_insert(whitelist, sc, sc);
            }
            sc[1]++;
        }
    }

    g_hash_table_iter_init(&iter, cursegment);
    while(g_hash_table_iter_next(&iter, &key, &value)){
        struct chunk_item* chunk = value;
        struct chunk_item* target = g_hash_table_lookup(chunkset, key);
        if(target){
            if(memcmp(target->hash, chunk->hash, 20)!=0){
                fprintf(stderr, "+Find a collision between %s <-> %s! Try to detect it!\n", target->suffix, suffix);
                fprintf(stderr, "+Details: MinHash = %s, Size %lld <-> %lld\n",
                        memcmp(target->minhash, chunk->minhash, 20) == 0?"True":"False",
                        target->fsize, chunk->fsize);
                collisions++;
            }else{
                dup_chunks++;
            }

            int read_back = 0;
            /*if(memcmp(target->minhash, minhash, 20) != 0){*/
                read_back = 1;
                int *sc = g_hash_table_lookup(whitelist, &target->sid);
                assert(sc);
                assert(sc[1]>0);
                if(enable_wl && sc[1] > wl_threshold){
                    read_back = 0;
                }
            /*} */

            if(read_back){
                chunks_read_back++;
                if(memcmp(target->hash, chunk->hash, 20)!=0){
                    fprintf(stderr, "-Collision Detected!\n");
                    detected_collisions++;
                }
            }
            target->rc++;
        }else{
            chunk->fid = file_count;
            chunk->sid = segment_count;
            memcpy(chunk->minhash, minhash, 20);
            memcpy(chunk->suffix, suffix, 8);
            g_hash_table_iter_steal(&iter);
            g_hash_table_insert(chunkset, chunk->hash, chunk);
        }
    }

    g_hash_table_destroy(whitelist);
}

static int detect_by_segment_minhash(char *hashfile_name, int enable_wl)
{
    char buf[MAXLINE];
    struct hashfile_handle *handle;
    const struct chunk_info *ci;
    time_t scan_start_time;
    int ret;

    handle = hashfile_open(hashfile_name);

    int total_chunks = 0;

    chunkset = g_hash_table_new_full(g_int_hash, hash_equal, NULL, free);

    GHashTable* minhashset = g_hash_table_new_full(g_int_hash, minhash_equal, free, NULL);

    if (!handle) {
        fprintf(stderr, "Error opening hash file: %d!", errno);
        return -1;
    }

    /* Go over the files in a hashfile */
    while (1) {
        ret = hashfile_next_file(handle);
        if (ret < 0) {
            fprintf(stderr,
                    "Cannot get next file from a hashfile: %d!\n",
                    errno);
            return -1;
        }

        /* exit the loop if it was the last file */
        if (ret == 0)
            break;

        memset(minhash, 0xff, 20);

        parse_file_suffix(hashfile_curfile_path(handle), suffix, 8);
        if(strncmp(suffix, "edu,", 4) == 0){
            strcpy(suffix, "edu,?");
        }else if(strlen(suffix) == 0){
            strcpy(suffix, ".None");
        }

        GHashTable *cursegment = g_hash_table_new_full(g_int_hash, hash_equal, NULL, free);

        while (1) {
            ci = hashfile_next_chunk(handle);
            if (!ci) /* exit the loop if it was the last chunk */
                break;

            struct chunk_item *chunk = malloc(sizeof(struct chunk_item));
            memset(chunk, 0, sizeof(*chunk));

            chunk->size = ci->size;
            memcpy(chunk->hash, ci->hash, hashfile_hash_size(handle)/8);
            memcpy(chunk->hash+hashfile_hash_size(handle)/8, &chunk->size, sizeof(chunk->size));

            chunk->rc = 1;

            chunk->fsize = hashfile_curfile_size(handle);

            if(memcmp(chunk->hash, minhash, 20) < 0){
                memcpy(minhash, chunk->hash, 20);
            }

            struct chunk_item* target = g_hash_table_lookup(cursegment, chunk->hash);
            if(target){
                if(memcmp(chunk->hash, target->hash, 20)!=0){
                    fprintf(stderr, "+Find an intra-file collision! Cannot be detected! File size = %lld, Type = %s\n",
                            hashfile_curfile_size(handle), suffix);
                    collisions++;
                }
                free(chunk);
                dup_chunks++;
            }else{
                g_hash_table_insert(cursegment, chunk->hash, chunk);
            }

            if(g_hash_table_size(cursegment) > min_segment_size){
                int bits;
                memcpy(&bits, chunk->hash, 4);
                if((bits & (segment_size-1)) == 0 || g_hash_table_size(cursegment) > max_segment_size){
                    /* A new segment */
                    if(!g_hash_table_contains(minhashset, minhash)){
                        char* new_minhash = malloc(sizeof(minhash));
                        memcpy(new_minhash, minhash, sizeof(minhash));
                        g_hash_table_insert(minhashset, new_minhash, new_minhash);
                    }

                    check_cursegment(cursegment, enable_wl);
                    g_hash_table_remove_all(cursegment);
                    memset(minhash, 0xff, 20);
                    segment_count++;
                }
            }

            total_chunks++;
        }

        if(!g_hash_table_contains(minhashset, minhash)){
            char* new_minhash = malloc(sizeof(minhash));
            memcpy(new_minhash, minhash, sizeof(minhash));
            g_hash_table_insert(minhashset, new_minhash, new_minhash);
        }

        check_cursegment(cursegment, enable_wl);

        g_hash_table_destroy(cursegment);
        file_count++;
        segment_count++;

    }

    hashfile_close(handle);

    g_hash_table_destroy(chunkset);

    fprintf(stderr, "# of chunks read back: %d; %.4f of total chunks, %.4f of dup chunks; %.4f D/R\n",
            chunks_read_back, 1.0*chunks_read_back/total_chunks,
            1.0*chunks_read_back/dup_chunks, 1.0*dup_chunks/total_chunks);
    fprintf(stderr, "# of hash collisions: %d; %d detected\n", collisions, detected_collisions);
    fprintf(stderr, "# of bins: %d\n", g_hash_table_size(minhashset));

    printf("%d\n%d\n%.4f\n%.4f\n", collisions, detected_collisions, 1.0*chunks_read_back/total_chunks, 1.0*chunks_read_back/dup_chunks);

    g_hash_table_destroy(minhashset);
    return 0;
}

static int detect_by_file_minhash(char *hashfile_name)
{
    char buf[MAXLINE];
    struct hashfile_handle *handle;
    const struct chunk_info *ci;
    time_t scan_start_time;
    int ret;

    handle = hashfile_open(hashfile_name);

    int total_chunks = 0;

    chunkset = g_hash_table_new_full(g_int_hash, hash_equal, NULL, free);

    if (!handle) {
        fprintf(stderr, "Error opening hash file: %d!", errno);
        return -1;
    }

    /* Go over the files in a hashfile */
    while (1) {
        ret = hashfile_next_file(handle);
        if (ret < 0) {
            fprintf(stderr,
                    "Cannot get next file from a hashfile: %d!\n",
                    errno);
            return -1;
        }

        /* exit the loop if it was the last file */
        if (ret == 0)
            break;

        memset(minhash, 0xff, 20);

        parse_file_suffix(hashfile_curfile_path(handle), suffix, 8);
        if(strncmp(suffix, "edu,", 4) == 0){
            strcpy(suffix, "edu,?");
        }else if(strlen(suffix) == 0){
            strcpy(suffix, ".None");
        }

        GHashTable *curfile = g_hash_table_new_full(g_int_hash, hash_equal, NULL, free);

        while (1) {
            ci = hashfile_next_chunk(handle);
            if (!ci) /* exit the loop if it was the last chunk */
                break;

            struct chunk_item *chunk = malloc(sizeof(struct chunk_item));
            memset(chunk, 0, sizeof(*chunk));

            chunk->size = ci->size;
            memcpy(chunk->hash, ci->hash, hashfile_hash_size(handle)/8);
            memcpy(chunk->hash+hashfile_hash_size(handle)/8, &chunk->size, sizeof(chunk->size));

            chunk->rc = 1;

            chunk->fsize = hashfile_curfile_size(handle);

            if(memcmp(chunk->hash, minhash, 20) < 0){
                memcpy(minhash, chunk->hash, 20);
            }

            struct chunk_item* target = g_hash_table_lookup(curfile, chunk->hash);
            if(target){
                if(target->size != chunk->size){
                    fprintf(stderr, "+Find an intra-file collision! Cannot be detected! File size = %lld, Type = %s\n",
                            hashfile_curfile_size(handle), suffix);
                    collisions++;
                }
                free(chunk);
                dup_chunks++;
            }else{
                g_hash_table_insert(curfile, chunk->hash, chunk);
            }

            total_chunks++;
        }

        check_curfile(curfile);
        g_hash_table_destroy(curfile);
        file_count++;

    }

    hashfile_close(handle);

    g_hash_table_destroy(chunkset);

    fprintf(stderr, "# of chunks read back: %d; %.4f of total chunks, %.4f of dup chunks\n",
            chunks_read_back, 1.0*chunks_read_back/total_chunks,
            1.0*chunks_read_back/dup_chunks);
    fprintf(stderr, "# of hash collisions: %d; %d detected\n", collisions, detected_collisions);
    printf("%d %d %.4f %.4f\n", collisions, detected_collisions, 1.0*chunks_read_back/total_chunks, 1.0*chunks_read_back/dup_chunks);
    return 0;
}

int main(int argc, char *argv[])
{
    int opt = 0;
    int segment = 0;
    int enable_wl = 0;
    while ((opt = getopt_long(argc, argv, "h:s:wt:", NULL, NULL))
            != -1) {
        switch (opt) {
            case 's':
                segment = 1;
                segment_size = atoi(optarg);
                min_segment_size = segment_size/4;
                max_segment_size = segment_size*4;
                break;
            case 'w':
                enable_wl = 1;
                break;
            case 'h':
                hashlen = atoi(optarg);
                break;
            case 't':
                wl_threshold = atoi(optarg);
                break;
            default:
                return -1;
        }
    }

    int ret;
    if(segment == 0)
        ret = detect_by_file_minhash(argv[optind]);
    else
        ret = detect_by_segment_minhash(argv[optind], enable_wl);

    return ret;
}


text:
package org.ovirt.engine.core.common.action;

import org.ovirt.engine.core.compat.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "VmOperationParameterBase")
public class VmOperationParameterBase extends VdcActionParametersBase implements java.io.Serializable {
    private static final long serialVersionUID = -6248335374537898949L;

    public VmOperationParameterBase() {
    }

    @XmlElement(name = "VmId")
    private Guid _vmId = new Guid();

    public VmOperationParameterBase(Guid vmId) {
        _vmId = vmId;
    }

    public Guid getVmId() {
        return _vmId;
    }

    public void setVmId(Guid value) {
        _vmId = value;
    }

}

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Fungal Diversity 32: 127 (2008)

#### Original name
Lactarius cinereobrunneus Stubbe & Verbeken

### Remarks
null


text:
package org.apache.metron.common.field.validation.primitive;

import org.apache.metron.common.field.validation.SimpleValidation;

import java.util.function.Predicate;

public class NotEmptyValidation extends SimpleValidation {
  @Override
  public Predicate<Object> getPredicate() {
    return s -> !(s == null || s.toString().trim().isEmpty());
  }

  @Override
  protected boolean isNonExistentOk() {
    return false;
  }
}


text:
package com.google.cloud.tools.eclipse.test.util.project;

import static org.junit.Assert.assertTrue;

import com.google.cloud.tools.eclipse.appengine.facets.AppEngineConfigurationUtil;
import com.google.cloud.tools.eclipse.appengine.facets.AppEngineStandardFacet;
import com.google.cloud.tools.eclipse.appengine.facets.FacetUtil;
import com.google.cloud.tools.eclipse.test.util.ThreadDumpingWatchdog;
import com.google.cloud.tools.eclipse.util.ClasspathUtil;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.common.project.facet.core.JavaFacet;
import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
import org.junit.rules.ExternalResource;

/**
 * Utility class to create and configure a Faceted Project. Installs a Java 1.7 facet if no facets
 * are specified with {@link #withFacets}.
 */
public final class TestProjectCreator extends ExternalResource {
  private static final Logger logger = Logger.getLogger(TestProjectCreator.class.getName());

  private IProject project;
  private IJavaProject javaProject;
  private IFacetedProject facetedProject;

  private String containerPath;
  private String appEngineServiceId;
  private final List<IProjectFacetVersion> projectFacetVersions = new ArrayList<>();
  private boolean makeFaceted;

  public TestProjectCreator withClasspathContainerPath(String containerPath) {
    this.containerPath = containerPath;
    return this;
  }

  public TestProjectCreator withFacets(IProjectFacetVersion... projectFacetVersions) {
    makeFaceted = true;
    Collections.addAll(this.projectFacetVersions, projectFacetVersions);
    return this;
  }

  public TestProjectCreator withFacets(List<IProjectFacetVersion> projectFacetVersions) {
    makeFaceted = true;
    this.projectFacetVersions.addAll(projectFacetVersions);
    return this;
  }

  public TestProjectCreator withAppEngineServiceId(String serviceId) {
    appEngineServiceId = serviceId;
    return this;
  }

  @Override
  protected void after() {
    if (project != null) {
      try {
        if (facetedProject != null && facetedProject.hasProjectFacet(WebFacetUtils.WEB_FACET)) {
          // Wait for the WTP validation job as it runs without the workspace protection lock
          ProjectUtils.waitForProjects(project);
        }
        try {
          project.close(new NullProgressMonitor());
        } catch (CoreException ex) {
          logger.log(Level.SEVERE, "Exception closing test project: " + project, ex);
        }
        project.delete(true, null);
      } catch (IllegalArgumentException ex) {
        ThreadDumpingWatchdog.report();
        throw ex;
      } catch (CoreException ex) {
        throw new AssertionError("Could not delete project", ex);
      }
    }
  }

  public IModule getModule() {
    createProjectIfNecessary();
    return ServerUtil.getModule(project);
  }

  public IJavaProject getJavaProject() {
    createProjectIfNecessary();
    Preconditions.checkState(javaProject != null);
    return javaProject;
  }

  public IProject getProject() {
    createProjectIfNecessary();
    return project;
  }

  public IFacetedProject getFacetedProject() {
    createProjectIfNecessary();
    Preconditions.checkState(facetedProject != null);
    return facetedProject;
  }

  private void createProjectIfNecessary() {
    if (project == null) {
      try {
        createProject("test" + Math.random());
      } catch (CoreException ex) {
        throw new AssertionError("Could not create project", ex);
      }
    }
  }

  private void createProject(String projectName) throws CoreException {
    IProjectDescription newProjectDescription =
        ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
    project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    project.create(newProjectDescription, null);
    project.open(null);

    addFacets();
    addContainerPathToRawClasspath();
    if (appEngineServiceId != null) {
      setAppEngineServiceId(appEngineServiceId);
    }
  }

  private void addContainerPathToRawClasspath() throws JavaModelException {
    if (!Strings.isNullOrEmpty(containerPath)) {
      Preconditions.checkNotNull(javaProject);
      IClasspathEntry container = JavaCore.newContainerEntry(new Path(containerPath));
      ClasspathUtil.addClasspathEntry(project, container, null);
    }
  }

  private void addFacets() throws CoreException {
    if (makeFaceted) {
      facetedProject = ProjectFacetsManager.create(project, true, null);
    }
    if (projectFacetVersions.isEmpty()) {
      return;
    }

    FacetUtil facetUtil = new FacetUtil(facetedProject);
    for (IProjectFacetVersion projectFacetVersion : projectFacetVersions) {
      facetUtil.addFacetToBatch(projectFacetVersion, null);
    }
    facetUtil.install(null);

    if (facetedProject.hasProjectFacet(AppEngineStandardFacet.FACET)) {
      // App Engine runtime is added via a Job, so wait.
      ProjectUtils.waitForProjects(project);
    }

    if (facetedProject.hasProjectFacet(JavaFacet.FACET)) {
      javaProject = JavaCore.create(project);
      assertTrue(javaProject.exists());
    }
  }

  private void setAppEngineServiceId(String serviceId) {
    IFile appEngineWebXml =
        AppEngineConfigurationUtil.findConfigurationFile(
            getProject(), new Path("appengine-web.xml"));
    assertTrue("Project should have AppEngine Standard facet", appEngineWebXml.exists());
    ConfigurationFileUtils.createAppEngineWebXml(project, serviceId);
  }

}


text:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<meta property="og:title" content="tamoc.dbm.FluidParticle.partial_pressures" />

<meta property="og:type" content="website" />

<meta property="og:url" content="generated/tamoc.dbm.FluidParticle.partial_pressures.html" />

    <title>tamoc.dbm.FluidParticle.partial_pressures</title>

  <link href="../_static/styles/theme.css?digest=1999514e3f237ded88cf" rel="stylesheet">
<link href="../_static/styles/pydata-sphinx-theme.css?digest=1999514e3f237ded88cf" rel="stylesheet">

  <link rel="stylesheet"
    href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
  <link rel="preload" as="font" type="font/woff2" crossorigin
    href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
  <link rel="preload" as="font" type="font/woff2" crossorigin
    href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" href="../_static/styles/sphinx-book-theme.css?digest=62ba249389abaaa9ffc34bf36a076bdc1d65ee18" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
    <link rel="stylesheet" type="text/css" href="../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
    <link rel="stylesheet" type="text/css" href="../_static/panels-bootstrap.5fd3999ee7762ccc51105388f4a9d115.css" />
    <link rel="stylesheet" type="text/css" href="../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />

  <link rel="preload" as="script" href="../_static/scripts/pydata-sphinx-theme.js?digest=1999514e3f237ded88cf">

    <link rel="shortcut icon" href="../_static/tamoc_favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="tamoc.dbm.FluidParticle.density" href="tamoc.dbm.FluidParticle.density.html" />
    <link rel="prev" title="tamoc.dbm.FluidParticle.mol_frac" href="tamoc.dbm.FluidParticle.mol_frac.html" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="docsearch:language" content="None">

<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation" aria-label="Toggle navigation sidebar">

Toggle navigation sidebar

<input type="checkbox" class="sidebar-toggle" name="__page-toc" id="__page-toc" aria-label="Toggle in-page Table of Contents">

Toggle in-page Table of Contents

<form class="bd-search d-flex align-items-center" action="../search.html" method="get">

  <input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form>

  Contents:

   Getting Started

  <input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>

     Installation

     How to use this documentation

     ReadMe File

     License

     Release Notes

     Reporting Bugs

   User's Guide

  <input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>

     Equations of State for Seawater

     Tools for Manipulating Ambient Profile Data

     Discrete Bubble Model

     Discrete Bubble Model – Properties Functions

     Dispersed Phases

     Single Bubble Model

     Stratified Plume Model User's Guide

     Bent Plume Model

     Params Module

     Blowout Module

     Particle Size Models

   Example Scripts

  <input class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" type="checkbox"/>

     Ambient Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/>

       bin.ambient.profile_from_txt

       bin.ambient.profile_from_lab

       bin.ambient.profile_from_ctd

       bin.ambient.profile_from_world_ocean

       bin.ambient.profile_append

       bin.ambient.profile_extending

       bin.ambient.nc_profile_from_txt

       bin.ambient.nc_profile_from_lab

       bin.ambient.nc_profile_from_ctd

       bin.ambient.nc_profile_append

       bin.ambient.nc_profile_extending

       bin.ambient.np_profile_from_txt

       bin.ambient.np_profile_from_lab

       bin.ambient.np_profile_from_ctd

     Discrete Particle Model Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" type="checkbox"/>

       bin.dbm.air_eos

       bin.dbm.co2_eos

       bin.dbm.dead_oil

       bin.dbm.gas_bubbles

       bin.dbm.hydrocarbon_drops

       bin.dbm.droplet_rise

       bin.dbm.equilibrium

     Single Bubble Model Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" type="checkbox"/>

       bin.sbm.bubble

       bin.sbm.drop

       bin.sbm.particle

       bin.sbm.sbm_file_io

       bin.sbm.seep_bubble

       bin.sbm.drop_biodeg

       bin.sbm.CO2_bubble

     Stratified Plume Model Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-7" name="toctree-checkbox-7" type="checkbox"/>

       bin.spm.lake_part

       bin.spm.lake_bub

       bin.spm.spm_blowout_sim

       bin.spm.spm_file_io

     Bent Plume Model Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-8" name="toctree-checkbox-8" type="checkbox"/>

       bin.bpm.crossflow_plume

       bin.bpm.bpm_blowout_sim

     Particle Size Model Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-9" name="toctree-checkbox-9" type="checkbox"/>

       bin.psm.oil_jet

       bin.psm.blowout_jet

     Blowout Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-10" name="toctree-checkbox-10" type="checkbox"/>

       bin.bpm.blowout_obj

     Non-Dimensional Parameters Scripts

    <input class="toctree-checkbox" id="toctree-checkbox-11" name="toctree-checkbox-11" type="checkbox"/>

       bin.params.scales

   API Reference

  <input checked="" class="toctree-checkbox" id="toctree-checkbox-12" name="toctree-checkbox-12" type="checkbox"/>

     Seawater Module

    <input class="toctree-checkbox" id="toctree-checkbox-13" name="toctree-checkbox-13" type="checkbox"/>

       tamoc.seawater

       tamoc.seawater.density

       tamoc.seawater.mu

       tamoc.seawater.sigma

       tamoc.seawater.k

       tamoc.seawater.cp

       tamoc.seawater.pH

     Ambient Module

    <input class="toctree-checkbox" id="toctree-checkbox-14" name="toctree-checkbox-14" type="checkbox"/>

       tamoc.ambient

       tamoc.ambient.Profile

       tamoc.ambient.BaseProfile

       tamoc.ambient.Profile.get_values

       tamoc.ambient.Profile.get_units

       tamoc.ambient.Profile.append

       tamoc.ambient.Profile.extend_profile_deeper

       tamoc.ambient.Profile.add_computed_gas_concentrations

       tamoc.ambient.Profile.buoyancy_frequency

       tamoc.ambient.Profile.insert_density

       tamoc.ambient.Profile.insert_potential_density

       tamoc.ambient.Profile.insert_buoyancy_frequency

       tamoc.ambient.Profile.plot_parameter

       tamoc.ambient.Profile.plot_profiles

       tamoc.ambient.Profile.plot_physical_profiles

       tamoc.ambient.Profile.plot_chem_profiles

       tamoc.ambient.Profile.close_nc

       tamoc.ambient.xr_check_units

       tamoc.ambient.xr_convert_units

       tamoc.ambient.xr_coarsen_dataset

       tamoc.ambient.xr_stabilize_dataset

       tamoc.ambient.xr_dataset_to_array

       tamoc.ambient.xr_array_to_dataset

       tamoc.ambient.xr_add_data_from_numpy

       tamoc.ambient.create_nc_db

       tamoc.ambient.fill_nc_db

       tamoc.ambient.fill_nc_db_variable

       tamoc.ambient.get_nc_data

       tamoc.ambient.get_xarray_data

       tamoc.ambient.add_data

       tamoc.ambient.extract_profile

       tamoc.ambient.coarsen

       tamoc.ambient.stabilize

       tamoc.ambient.compute_pressure

       tamoc.ambient.convert_units

       tamoc.ambient.get_world_ocean

       tamoc.ambient.load_raw

     Discrete Particle Module

    <input checked="" class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/>

       tamoc.dbm

       tamoc.dbm.FluidMixture

       tamoc.dbm.FluidParticle

       tamoc.dbm.InsolubleParticle

       tamoc.dbm.FluidMixture.masses

       tamoc.dbm.FluidMixture.mass_frac

       tamoc.dbm.FluidMixture.moles

       tamoc.dbm.FluidMixture.mol_frac

       tamoc.dbm.FluidMixture.partial_pressures

       tamoc.dbm.FluidMixture.density

       tamoc.dbm.FluidMixture.fugacity

       tamoc.dbm.FluidMixture.viscosity

       tamoc.dbm.FluidMixture.interface_tension

       tamoc.dbm.FluidMixture.equilibrium

       tamoc.dbm.FluidMixture.solubility

       tamoc.dbm.FluidMixture.diffusivity

       tamoc.dbm.FluidMixture.hydrate_stability

       tamoc.dbm.FluidMixture.biodegradation_rate

       tamoc.dbm.FluidParticle.masses

       tamoc.dbm.FluidParticle.mass_frac

       tamoc.dbm.FluidParticle.moles

       tamoc.dbm.FluidParticle.mol_frac

       tamoc.dbm.FluidParticle.partial_pressures

       tamoc.dbm.FluidParticle.density

       tamoc.dbm.FluidParticle.fugacity

       tamoc.dbm.FluidParticle.viscosity

       tamoc.dbm.FluidParticle.interface_tension

       tamoc.dbm.FluidParticle.equilibrium

       tamoc.dbm.FluidParticle.solubility

       tamoc.dbm.FluidParticle.diffusivity

       tamoc.dbm.FluidParticle.hydrate_stability

       tamoc.dbm.FluidParticle.biodegradation_rate

       tamoc.dbm.FluidParticle.masses_by_diameter

       tamoc.dbm.FluidParticle.diameter

       tamoc.dbm.FluidParticle.particle_shape

       tamoc.dbm.FluidParticle.slip_velocity

       tamoc.dbm.FluidParticle.surface_area

       tamoc.dbm.FluidParticle.mass_transfer

       tamoc.dbm.FluidParticle.heat_transfer

       tamoc.dbm.FluidParticle.return_all

       tamoc.dbm.InsolubleParticle.density

       tamoc.dbm.InsolubleParticle.viscosity

       tamoc.dbm.InsolubleParticle.interface_tension

       tamoc.dbm.InsolubleParticle.biodegradation_rate

       tamoc.dbm.InsolubleParticle.mass_by_diameter

       tamoc.dbm.InsolubleParticle.diameter

       tamoc.dbm.InsolubleParticle.particle_shape

       tamoc.dbm.InsolubleParticle.slip_velocity

       tamoc.dbm.InsolubleParticle.surface_area

       tamoc.dbm.InsolubleParticle.heat_transfer

       tamoc.dbm.InsolubleParticle.return_all

       tamoc.dbm.equil_MM

       tamoc.dbm.stability_analysis

       tamoc.dbm.successive_substitution

       tamoc.dbm.gas_liq_eq

     Discrete Particle Module – Properties Functions

    <input class="toctree-checkbox" id="toctree-checkbox-16" name="toctree-checkbox-16" type="checkbox"/>

       tamoc.dbm_p

       tamoc.dbm_p.cubic_roots

       tamoc.dbm_p.eotvos

       tamoc.dbm_p.morton

       tamoc.dbm_p.reynolds

       tamoc.dbm_p.h_parameter

       tamoc.dbm_p.particle_shape

       tamoc.dbm_p.theta_w_sc

       tamoc.dbm_p.surface_area_sc

       tamoc.dbm_p.surface_area_sphere

       tamoc.dbm_p.us_sphere

       tamoc.dbm_p.us_ellipsoid

       tamoc.dbm_p.us_spherical_cap

       tamoc.dbm_p.xfer_kumar_hartland

       tamoc.dbm_p.xfer_johnson

       tamoc.dbm_p.xfer_clift

       tamoc.dbm_p.xfer_sphere

       tamoc.dbm_p.xfer_ellipsoid

       tamoc.dbm_p.xfer_spherical_cap

       tamoc.dbm_p.density

       tamoc.dbm_p.fugacity

       tamoc.dbm_p.volume_trans

       tamoc.dbm_p.z_pr

       tamoc.dbm_p.coefs

       tamoc.dbm_p.mole_fraction

       tamoc.dbm_p.viscosity

       tamoc.dbm_p.kh_insitu

       tamoc.dbm_p.sw_solubility

       tamoc.dbm_p.diffusivity

       tamoc.dbm_p.kvsi_hydrate

     DBM Utilities Module

    <input class="toctree-checkbox" id="toctree-checkbox-17" name="toctree-checkbox-17" type="checkbox"/>

       tamoc.dbm_utilities

       tamoc.dbm_utilities.get_oil

       tamoc.dbm_utilities.load_tamoc_oil

       tamoc.dbm_utilities.format_dbm_data

       tamoc.dbm_utilities.mix_gas_for_gor

       tamoc.dbm_utilities.natural_gas

       tamoc.dbm_utilities.gas_fraction

       tamoc.dbm_utilities.set_mass_fluxes

       tamoc.dbm_utilities.load_adios_oil

       tamoc.dbm_utilities.load_simap_oil

       tamoc.dbm_utilities.sequence_names

       tamoc.dbm_utilities.get_solubility

       tamoc.dbm_utilities.get_henry_constant

       tamoc.dbm_utilities.get_preos_params

       tamoc.dbm_utilities.pedersen

       tamoc.dbm_utilities.compute_Vb

       tamoc.dbm_utilities.Vc_tuning

       tamoc.dbm_utilities.print_chemdata

       tamoc.dbm_utilities.print_composition

       tamoc.dbm_utilities.print_petroleum_props

     Dispersed Phases Module

    <input class="toctree-checkbox" id="toctree-checkbox-18" name="toctree-checkbox-18" type="checkbox"/>

       tamoc.dispersed_phases

       tamoc.dispersed_phases.SingleParticle

       tamoc.dispersed_phases.PlumeParticle

       tamoc.dispersed_phases.SingleParticle.properties

       tamoc.dispersed_phases.SingleParticle.diameter

       tamoc.dispersed_phases.SingleParticle.biodegradation_rate

       tamoc.dispersed_phases.PlumeParticle.properties

       tamoc.dispersed_phases.PlumeParticle.diameter

       tamoc.dispersed_phases.PlumeParticle.biodegradation_rate

       tamoc.dispersed_phases.PlumeParticle.update

       tamoc.dispersed_phases.initial_conditions

       tamoc.dispersed_phases.save_particle_to_nc_file

       tamoc.dispersed_phases.load_particle_from_nc_file

       tamoc.dispersed_phases.shear_entrainment

       tamoc.dispersed_phases.hydrate_formation_time

       tamoc.dispersed_phases.zfe_volume_flux

       tamoc.dispersed_phases.wuest_ic

       tamoc.dispersed_phases.bf_average

       tamoc.dispersed_phases.get_chem_names

       tamoc.dispersed_phases.particles_state_space

     Single Bubble Model Module

    <input class="toctree-checkbox" id="toctree-checkbox-19" name="toctree-checkbox-19" type="checkbox"/>

       tamoc.single_bubble_model

       tamoc.single_bubble_model.Model

       tamoc.single_bubble_model.ModelParams

       tamoc.single_bubble_model.Model.simulate

       tamoc.single_bubble_model.Model.save_sim

       tamoc.single_bubble_model.Model.save_txt

       tamoc.single_bubble_model.Model.load_sim

       tamoc.single_bubble_model.Model.post_process

       tamoc.single_bubble_model.calculate_path

       tamoc.single_bubble_model.derivs

       tamoc.single_bubble_model.sbm_ic

       tamoc.single_bubble_model.plot_state_space

     Stratified Plume Model Module

    <input class="toctree-checkbox" id="toctree-checkbox-20" name="toctree-checkbox-20" type="checkbox"/>

       tamoc.stratified_plume_model

       tamoc.stratified_plume_model.Model

       tamoc.stratified_plume_model.ModelParams

       tamoc.stratified_plume_model.InnerPlume

       tamoc.stratified_plume_model.OuterPlume

       tamoc.stratified_plume_model.Model.simulate

       tamoc.stratified_plume_model.Model.save_sim

       tamoc.stratified_plume_model.Model.save_txt

       tamoc.stratified_plume_model.Model.load_sim

       tamoc.stratified_plume_model.Model.plot_state_space

       tamoc.stratified_plume_model.Model.plot_all_variables

       tamoc.stratified_plume_model.InnerPlume.update

       tamoc.stratified_plume_model.OuterPlume.update

       tamoc.stratified_plume_model.inner_main

       tamoc.stratified_plume_model.outer_main

       tamoc.stratified_plume_model.err_check

       tamoc.stratified_plume_model.particle_from_Q

       tamoc.stratified_plume_model.particle_from_mb0

       tamoc.stratified_plume_model.plot_state_space

       tamoc.stratified_plume_model.plot_all_variables

     Bent Plume Model Module

    <input class="toctree-checkbox" id="toctree-checkbox-21" name="toctree-checkbox-21" type="checkbox"/>

       tamoc.bent_plume_model

       tamoc.bent_plume_model.Model

       tamoc.bent_plume_model.ModelParams

       tamoc.bent_plume_model.Particle

       tamoc.bent_plume_model.LagElement

       tamoc.bent_plume_model.Model.simulate

       tamoc.bent_plume_model.Model.get_intrusion_concentration

       tamoc.bent_plume_model.Model.get_grid_concentrations

       tamoc.bent_plume_model.Model.get_planar_concentrations

       tamoc.bent_plume_model.Model.save_sim

       tamoc.bent_plume_model.Model.save_txt

       tamoc.bent_plume_model.Model.load_sim

       tamoc.bent_plume_model.Model.report_mass_fluxes

       tamoc.bent_plume_model.Model.report_surfacing_fluxes

       tamoc.bent_plume_model.Model.report_psds

       tamoc.bent_plume_model.Model.plot_psds

       tamoc.bent_plume_model.Model.plot_state_space

       tamoc.bent_plume_model.Model.plot_all_variables

       tamoc.bent_plume_model.Model.plot_fractions_dissolved

       tamoc.bent_plume_model.Model.plot_mass_balance

       tamoc.bent_plume_model.Particle.track

       tamoc.bent_plume_model.Particle.outside

       tamoc.bent_plume_model.Particle.run_sbm

       tamoc.bent_plume_model.Particle.point_concentration

       tamoc.bent_plume_model.Particle.grid_concentrations

       tamoc.bent_plume_model.LagElement.update

       tamoc.bent_plume_model.plot_state_space

       tamoc.bent_plume_model.plot_all_variables

       tamoc.bent_plume_model.width_projection

       tamoc.bent_plume_model.chem_idx_list

     Particle Size Model Module

    <input class="toctree-checkbox" id="toctree-checkbox-22" name="toctree-checkbox-22" type="checkbox"/>

       tamoc.particle_size_models

       tamoc.particle_size_models.Model

       tamoc.particle_size_models.PureJet

       tamoc.particle_size_models.ModelBase

       tamoc.particle_size_models.Model.update_properties

       tamoc.particle_size_models.Model.update_z0

       tamoc.particle_size_models.Model.update_Tj

       tamoc.particle_size_models.Model.update_m_mixture

       tamoc.particle_size_models.Model.simulate

       tamoc.particle_size_models.Model.get_de_max

       tamoc.particle_size_models.Model.get_d50

       tamoc.particle_size_models.Model.get_distributions

       tamoc.particle_size_models.Model.plot_psd

       tamoc.particle_size_models.PureJet.update_properties

       tamoc.particle_size_models.PureJet.simulate

       tamoc.particle_size_models.PureJet.get_de_max

       tamoc.particle_size_models.PureJet.get_d50

       tamoc.particle_size_models.PureJet.get_distributions

       tamoc.particle_size_models.PureJet.plot_psd

       tamoc.particle_size_models.ModelBase.update_properties

       tamoc.particle_size_models.ModelBase.simulate

       tamoc.particle_size_models.ModelBase.get_de_max

       tamoc.particle_size_models.ModelBase.get_d50

       tamoc.particle_size_models.ModelBase.get_distributions

       tamoc.particle_size_models.ModelBase.plot_psd

       tamoc.particle_size_models.plot_phase

     Blowout Module

    <input class="toctree-checkbox" id="toctree-checkbox-23" name="toctree-checkbox-23" type="checkbox"/>

       tamoc.blowout

       tamoc.blowout.Blowout

       tamoc.blowout.Blowout.simulate

       tamoc.blowout.Blowout.save_sim

       tamoc.blowout.Blowout.save_txt

       tamoc.blowout.Blowout.plot_state_space

       tamoc.blowout.Blowout.plot_all_variables

       tamoc.blowout.Blowout.update_release_depth

       tamoc.blowout.Blowout.update_orifice_diameter

       tamoc.blowout.Blowout.update_substance

       tamoc.blowout.Blowout.update_q_oil

       tamoc.blowout.Blowout.update_gor

       tamoc.blowout.Blowout.update_produced_water

       tamoc.blowout.Blowout.update_vertical_orientation

       tamoc.blowout.Blowout.update_horizontal_orientation

       tamoc.blowout.Blowout.update_num_gas_elements

       tamoc.blowout.Blowout.update_water_data

       tamoc.blowout.Blowout.update_current_data

       tamoc.blowout.Blowout.update_track_particles

       tamoc.blowout.particles

       tamoc.blowout.get_ambient_profile

       tamoc.blowout.get_ctd_from_txt

       tamoc.blowout.create_ambient_profile

     Non-Dimensional Parameters Module

    <input class="toctree-checkbox" id="toctree-checkbox-24" name="toctree-checkbox-24" type="checkbox"/>

       tamoc.params

       tamoc.params.Scales

       tamoc.params.Scales.simulate

       tamoc.params.Scales.save_txt

       tamoc.params.Scales.get_variables

       tamoc.params.Scales.h_T

       tamoc.params.Scales.h_P

       tamoc.params.Scales.h_S

       tamoc.params.Scales.lambda_1

       tamoc.params.Scales.u_inf_crit

  Source Code:

   Test Package

  <input class="toctree-checkbox" id="toctree-checkbox-25" name="toctree-checkbox-25" type="checkbox"/>

     tamoc.test.test_ambient

     tamoc.test.test_blowout

     tamoc.test.test_bpm

     tamoc.test.test_dbm_f

     tamoc.test.test_dbm_objects

     tamoc.test.test_dbm

     tamoc.test.test_params

     tamoc.test.test_psm

     tamoc.test.test_sbm

     tamoc.test.test_sintef

     tamoc.test.test_spm

   GitHub repository

            Theme by the Executable Book Project

<button onclick="toggleFullScreen()"
  class="headerbtn"
  data-toggle="tooltip"
data-placement="bottom"
title="Fullscreen mode"
>

</button>

  <button class="headerbtn menu-dropdown__trigger"
      aria-label="Download this page">

  </button>

.rst

<button onclick="printPdf(this)"
  class="headerbtn"
  data-toggle="tooltip"
data-placement="left"
title="Print to PDF"
>

.pdf
</button>

tamoc.dbm.FluidParticle.partial_pressures

tamoc.dbm.FluidParticle.partial_pressures#

FluidParticle.partial_pressures(m, P)[source]#

Compute the partial pressure (Pa) of each component in a mixture.

Parameters

m (ndarray, size (nc)) – masses of each component in a mixture (kg)

P (float) – mixture pressure (Pa)

Returns

Pk (ndarray, size (nc)) – partial pressures of each component in a mixture (Pa)

previous

tamoc.dbm.FluidParticle.mol_frac

next

tamoc.dbm.FluidParticle.density

    By Scott A. Socolofsky

      © Copyright 2022, Scott A. Socolofsky.


text:
package com.amazonaws.services.datapipeline.model.transform;

import java.util.Map;
import java.util.Map.Entry;

import com.amazonaws.services.datapipeline.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;

import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;

/**
 * DeactivatePipelineResult JSON Unmarshaller
 */
public class DeactivatePipelineResultJsonUnmarshaller implements
        Unmarshaller<DeactivatePipelineResult, JsonUnmarshallerContext> {

    public DeactivatePipelineResult unmarshall(JsonUnmarshallerContext context)
            throws Exception {
        DeactivatePipelineResult deactivatePipelineResult = new DeactivatePipelineResult();

        return deactivatePipelineResult;
    }

    private static DeactivatePipelineResultJsonUnmarshaller instance;

    public static DeactivatePipelineResultJsonUnmarshaller getInstance() {
        if (instance == null)
            instance = new DeactivatePipelineResultJsonUnmarshaller();
        return instance;
    }
}


text:
/*
  +----------------------------------------------------------------------+
  | Swoole                                                               |
  +----------------------------------------------------------------------+
  | This source file is subject to version 2.0 of the Apache license,    |
  | that is bundled with this package in the file LICENSE, and is        |
  | available through the world-wide-web at the following url:           |
  | http://www.apache.org/licenses/LICENSE-2.0.html                      |
  | If you did not receive a copy of the Apache2.0 license and are unable|
  | to obtain it through the world-wide-web, please send a note to       |
  | license@swoole.com so we can mail you a copy immediately.            |
  +----------------------------------------------------------------------+
  | Author: Tianfeng Han  <mikan.tenny@gmail.com>                        |
  +----------------------------------------------------------------------+
*/

#include "swoole.h"

#ifdef HAVE_EVENTFD
#include <sys/eventfd.h>

static int swPipeEventfd_read(swPipe *p, void *data, int length);
static int swPipeEventfd_write(swPipe *p, void *data, int length);
static int swPipeEventfd_close(swPipe *p);

typedef struct _swPipeEventfd
{
    int event_fd;
} swPipeEventfd;

int swPipeEventfd_create(swPipe *p, int blocking, int semaphore, int timeout)
{
    int efd;
    int flag = 0;
    swPipeEventfd *object = sw_malloc(sizeof(swPipeEventfd));
    if (object == NULL)
    {
        return -1;
    }

    flag = EFD_NONBLOCK;

    if (blocking == 1)
    {
        if (timeout > 0)
        {
            flag = 0;
            p->timeout = -1;
        }
        else
        {
            p->timeout = timeout;
        }
    }

#ifdef EFD_SEMAPHORE
    if (semaphore == 1)
    {
        flag |= EFD_SEMAPHORE;
    }
#endif

    p->blocking = blocking;
    efd = eventfd(0, flag);
    if (efd < 0)
    {
        swSysWarn("eventfd create failed");
        sw_free(object);
        return -1;
    }
    else
    {
        p->master_socket = swSocket_new(efd, SW_FD_PIPE);
        if (p->master_socket == NULL)
        {
            close(efd);
            sw_free(object);
            return -1;
        }
        p->worker_socket = p->master_socket;
        p->object = object;
        p->read = swPipeEventfd_read;
        p->write = swPipeEventfd_write;
        p->getSocket = swPipe_getSocket;
        p->close = swPipeEventfd_close;
        object->event_fd = efd;
    }
    return 0;
}

static int swPipeEventfd_read(swPipe *p, void *data, int length)
{
    int ret = -1;
    swPipeEventfd *object = p->object;

    //eventfd not support socket timeout
    if (p->blocking == 1 && p->timeout > 0)
    {
        if (swSocket_wait(object->event_fd, p->timeout * 1000, SW_EVENT_READ) < 0)
        {
            return SW_ERR;
        }
    }

    while (1)
    {
        ret = read(object->event_fd, data, sizeof(uint64_t));
        if (ret < 0 && errno == EINTR)
        {
            continue;
        }
        break;
    }
    return ret;
}

static int swPipeEventfd_write(swPipe *p, void *data, int length)
{
    int ret;
    swPipeEventfd *object = p->object;
    while (1)
    {
        ret = write(object->event_fd, data, sizeof(uint64_t));
        if (ret < 0)
        {
            if (errno == EINTR)
            {
                continue;
            }
        }
        break;
    }
    return ret;
}

static int swPipeEventfd_close(swPipe *p)
{
    swSocket_free(p->master_socket);
    sw_free(p->object);
    return SW_OK;
}

#endif


text:
ga-dashboard-graph-bars
=======================

Render a bars graph in panel as in `Gentelella index`_. The graph consists of :doc:`ga-progress` bars.

.. _Gentelella index: https://colorlib.com/polygon/gentelella/index.html

.. image:: images/ga-dashboard-graph-bars.png

Binding reference
-----------------

- ``graph-title``: The graph panel title (string)
- ``graph-sub-title``: The subtitle presented next to title in smaller font size (string)
- ``graph-heading``: The heading in the content (string)
- ``graph-data``: The main graph data (array)

The graph data should follow the format:

::

  [{lower: 1, upper: 5, percentage: 15, count: 6}, ...]

Transclude
----------

The component allows the transclude of further content below.

Code sample
-----------

::

    <ga-dashboard-graph-bars graph-title="Age distribution"
                             graph-heading="Percentage per age class"
                             graph-data="$ctrl.dashboard.ages"></ga-dashboard-graph-bars>


text:
package org.elasticsearch.cluster;

import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;

import org.elasticsearch.Version;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.VersionedNamedWriteable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.discovery.zen.PublishClusterStateAction;

import java.io.IOException;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Represents the current state of the cluster.
 *

 * The cluster state object is immutable with the exception of the {@link RoutingNodes} structure, which is
 * built on demand from the {@link RoutingTable}.
 * The cluster state can be updated only on the master node. All updates are performed by on a
 * single thread and controlled by the {@link ClusterService}. After every update the
 * {@link Discovery#publish} method publishes a new version of the cluster state to all other nodes in the
 * cluster.  The actual publishing mechanism is delegated to the {@link Discovery#publish} method and depends on
 * the type of discovery. In the Zen Discovery it is handled in the {@link PublishClusterStateAction#publish} method. The
 * publishing mechanism can be overridden by other discovery.
 *

 * The cluster state implements the {@link Diffable} interface in order to support publishing of cluster state
 * differences instead of the entire state on each change. The publishing mechanism should only send differences
 * to a node if this node was present in the previous version of the cluster state. If a node was
 * not present in the previous version of the cluster state, this node is unlikely to have the previous cluster
 * state version and should be sent a complete version. In order to make sure that the differences are applied to the
 * correct version of the cluster state, each cluster state version update generates {@link #stateUUID} that uniquely
 * identifies this version of the state. This uuid is verified by the {@link ClusterStateDiff#apply} method to
 * make sure that the correct diffs are applied. If uuids don't match, the {@link ClusterStateDiff#apply} method
 * throws the {@link IncompatibleClusterStateVersionException}, which causes the publishing mechanism to send
 * a full version of the cluster state to the node on which this exception was thrown.
 */
public class ClusterState implements ToXContentFragment, Diffable<ClusterState> {

    public static final ClusterState EMPTY_STATE = builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();

    /**
     * An interface that implementors use when a class requires a client to maybe have a feature.
     */
    public interface FeatureAware {

        /**
         * An optional feature that is required for the client to have.
         *
         * @return an empty optional if no feature is required otherwise a string representing the required feature
         */
        default Optional<String> getRequiredFeature() {
            return Optional.empty();
        }

        /**
         * Tests whether or not the custom should be serialized. The criteria are:
         *

         *
the output stream must be at least the minimum supported version of the custom

         *
the output stream must have the feature required by the custom (if any) or not be a transport client

         *

         *

         * That is, we only serialize customs to clients than can understand the custom based on the version of the client and the features
         * that the client has. For transport clients we can be lenient in requiring a feature in which case we do not send the custom but
         * for connected nodes we always require that the node has the required feature.
         *
         * @param out    the output stream
         * @param custom the custom to serialize
         * @param <T>    the type of the custom
         * @return true if the custom should be serialized and false otherwise
         */
        static <T extends VersionedNamedWriteable & FeatureAware> boolean shouldSerialize(final StreamOutput out, final T custom) {
            if (out.getVersion().before(custom.getMinimalSupportedVersion())) {
                return false;
            }
            if (custom.getRequiredFeature().isPresent()) {
                final String requiredFeature = custom.getRequiredFeature().get();
                // if it is a transport client we are lenient yet for a connected node it must have the required feature
                return out.hasFeature(requiredFeature) || out.hasFeature(TransportClient.TRANSPORT_CLIENT_FEATURE) == false;
            }
            return true;
        }

    }

    public interface Custom extends NamedDiffable<Custom>, ToXContentFragment, FeatureAware {

        /**
         * Returns true iff this {@link Custom} is private to the cluster and should never be send to a client.
         * The default is false;
         */
        default boolean isPrivate() {
            return false;
        }

    }

    private static final NamedDiffableValueSerializer<Custom> CUSTOM_VALUE_SERIALIZER = new NamedDiffableValueSerializer<>(Custom.class);

    public static final String UNKNOWN_UUID = "_na_";

    public static final long UNKNOWN_VERSION = -1;

    /**
     * ClusterState version number unique generator
     */
    private static final AtomicLong versionGenerator = new AtomicLong(0);

    private final long version;

    private final String stateUUID;

    private final RoutingTable routingTable;

    private final DiscoveryNodes nodes;

    private final MetaData metaData;

    private final ClusterBlocks blocks;

    private final ImmutableOpenMap<String, Custom> customs;

    private final ClusterName clusterName;

    private final boolean wasReadFromDiff;

    private final int minimumMasterNodesOnPublishingMaster;

    // built on demand
    private volatile RoutingNodes routingNodes;

    public ClusterState(long version, String stateUUID, ClusterState state) {
        this(state.clusterName, version, stateUUID, state.metaData(), state.routingTable(), state.nodes(), state.blocks(), state.customs(),
            -1, false);
    }

    public ClusterState(ClusterName clusterName, long version, String stateUUID, MetaData metaData, RoutingTable routingTable,
                        DiscoveryNodes nodes, ClusterBlocks blocks, ImmutableOpenMap<String, Custom> customs,
                        int minimumMasterNodesOnPublishingMaster, boolean wasReadFromDiff) {
        this.version = version;
        this.stateUUID = stateUUID;
        this.clusterName = clusterName;
        this.metaData = metaData;
        this.routingTable = routingTable;
        this.nodes = nodes;
        this.blocks = blocks;
        this.customs = customs;
        this.minimumMasterNodesOnPublishingMaster = minimumMasterNodesOnPublishingMaster;
        this.wasReadFromDiff = wasReadFromDiff;
    }

    public long version() {
        return this.version;
    }

    public long getVersion() {
        return version();
    }

    /**
     * This stateUUID is automatically generated for for each version of cluster state. It is used to make sure that
     * we are applying diffs to the right previous state.
     */
    public String stateUUID() {
        return this.stateUUID;
    }

    public DiscoveryNodes nodes() {
        return this.nodes;
    }

    public DiscoveryNodes getNodes() {
        return nodes();
    }

    public MetaData metaData() {
        return this.metaData;
    }

    public MetaData getMetaData() {
        return metaData();
    }

    public RoutingTable routingTable() {
        return routingTable;
    }

    public RoutingTable getRoutingTable() {
        return routingTable();
    }

    public ClusterBlocks blocks() {
        return this.blocks;
    }

    public ClusterBlocks getBlocks() {
        return blocks;
    }

    public ImmutableOpenMap<String, Custom> customs() {
        return this.customs;
    }

    public ImmutableOpenMap<String, Custom> getCustoms() {
        return this.customs;
    }

    public <T extends Custom> T custom(String type) {
        return (T) customs.get(type);
    }

    public ClusterName getClusterName() {
        return this.clusterName;
    }

    /**
     * The node-level `discovery.zen.minimum_master_nodes` setting on the master node that published this cluster state, for use in rolling
     * upgrades from 6.x to 7.x. Once all the 6.x master-eligible nodes have left the cluster, the 7.x nodes use this value to determine how
     * many master-eligible nodes must be discovered before the cluster can be bootstrapped. Note that this method returns the node-level
     * value of this setting, and ignores any cluster-level override that was set via the API. Callers are expected to combine this value
     * with any value set in the cluster-level settings. This should be removed once we no longer need support for {@link Version#V_6_7_0}.
     */
    public int getMinimumMasterNodesOnPublishingMaster() {
        return minimumMasterNodesOnPublishingMaster;
    }

    // Used for testing and logging to determine how this cluster state was send over the wire
    public boolean wasReadFromDiff() {
        return wasReadFromDiff;
    }

    /**
     * Returns a built (on demand) routing nodes view of the routing table.
     */
    public RoutingNodes getRoutingNodes() {
        if (routingNodes != null) {
            return routingNodes;
        }
        routingNodes = new RoutingNodes(this);
        return routingNodes;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("cluster uuid: ").append(metaData.clusterUUID()).append("\n");
        sb.append("version: ").append(version).append("\n");
        sb.append("state uuid: ").append(stateUUID).append("\n");
        sb.append("from_diff: ").append(wasReadFromDiff).append("\n");
        sb.append("meta data version: ").append(metaData.version()).append("\n");
        final String TAB = "   ";
        for (IndexMetaData indexMetaData : metaData) {
            sb.append(TAB).append(indexMetaData.getIndex());
            sb.append(": v[").append(indexMetaData.getVersion())
                    .append("], mv[").append(indexMetaData.getMappingVersion())
                    .append("], sv[").append(indexMetaData.getSettingsVersion())
                    .append("]\n");
            for (int shard = 0; shard < indexMetaData.getNumberOfShards(); shard++) {
                sb.append(TAB).append(TAB).append(shard).append(": ");
                sb.append("p_term [").append(indexMetaData.primaryTerm(shard)).append("], ");
                sb.append("isa_ids ").append(indexMetaData.inSyncAllocationIds(shard)).append("\n");
            }
        }
        if (metaData.customs().isEmpty() == false) {
            sb.append("metadata customs:\n");
            for (final ObjectObjectCursor<String, MetaData.Custom> cursor : metaData.customs()) {
                final String type = cursor.key;
                final MetaData.Custom custom = cursor.value;
                sb.append(TAB).append(type).append(": ").append(custom);
            }
            sb.append("\n");
        }
        sb.append(blocks());
        sb.append(nodes());
        sb.append(routingTable());
        sb.append(getRoutingNodes());
        if (customs.isEmpty() == false) {
            sb.append("customs:\n");
            for (ObjectObjectCursor<String, Custom> cursor : customs) {
                final String type = cursor.key;
                final Custom custom = cursor.value;
                sb.append(TAB).append(type).append(": ").append(custom);
            }
        }
        return sb.toString();
    }

    /**
     * a cluster state supersedes another state if they are from the same master and the version of this state is higher than that of the
     * other state.
     *

     * In essence that means that all the changes from the other cluster state are also reflected by the current one
     */
    public boolean supersedes(ClusterState other) {
        return this.version() > other.version();

    }

    public enum Metric {
        VERSION("version"),
        MASTER_NODE("master_node"),
        BLOCKS("blocks"),
        NODES("nodes"),
        METADATA("metadata"),
        ROUTING_TABLE("routing_table"),
        ROUTING_NODES("routing_nodes"),
        CUSTOMS("customs");

        private static Map<String, Metric> valueToEnum;

        static {
            valueToEnum = new HashMap<>();
            for (Metric metric : Metric.values()) {
                valueToEnum.put(metric.value, metric);
            }
        }

        private final String value;

        Metric(String value) {
            this.value = value;
        }

        public static EnumSet<Metric> parseString(String param, boolean ignoreUnknown) {
            String[] metrics = Strings.splitStringByCommaToArray(param);
            EnumSet<Metric> result = EnumSet.noneOf(Metric.class);
            for (String metric : metrics) {
                if ("_all".equals(metric)) {
                    result = EnumSet.allOf(Metric.class);
                    break;
                }
                Metric m = valueToEnum.get(metric);
                if (m == null) {
                    if (!ignoreUnknown) {
                        throw new IllegalArgumentException("Unknown metric [" + metric + "]");
                    }
                } else {
                    result.add(m);
                }
            }
            return result;
        }

        @Override
        public String toString() {
            return value;
        }
    }

    @Override
    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        EnumSet<Metric> metrics = Metric.parseString(params.param("metric", "_all"), true);

        // always provide the cluster_uuid as part of the top-level response (also part of the metadata response)
        builder.field("cluster_uuid", metaData().clusterUUID());

        if (metrics.contains(Metric.VERSION)) {
            builder.field("version", version);
            builder.field("state_uuid", stateUUID);
        }

        if (metrics.contains(Metric.MASTER_NODE)) {
            builder.field("master_node", nodes().getMasterNodeId());
        }

        if (metrics.contains(Metric.BLOCKS)) {
            builder.startObject("blocks");

            if (!blocks().global().isEmpty()) {
                builder.startObject("global");
                for (ClusterBlock block : blocks().global()) {
                    block.toXContent(builder, params);
                }
                builder.endObject();
            }

            if (!blocks().indices().isEmpty()) {
                builder.startObject("indices");
                for (ObjectObjectCursor<String, Set<ClusterBlock>> entry : blocks().indices()) {
                    builder.startObject(entry.key);
                    for (ClusterBlock block : entry.value) {
                        block.toXContent(builder, params);
                    }
                    builder.endObject();
                }
                builder.endObject();
            }

            builder.endObject();
        }

        // nodes
        if (metrics.contains(Metric.NODES)) {
            builder.startObject("nodes");
            for (DiscoveryNode node : nodes) {
                node.toXContent(builder, params);
            }
            builder.endObject();
        }

        // meta data
        if (metrics.contains(Metric.METADATA)) {
            builder.startObject("metadata");
            builder.field("version", metaData().version());
            builder.field("cluster_uuid", metaData().clusterUUID());
            builder.startObject("templates");
            for (ObjectCursor<IndexTemplateMetaData> cursor : metaData().templates().values()) {
                IndexTemplateMetaData templateMetaData = cursor.value;
                builder.startObject(templateMetaData.name());

                builder.field("index_patterns", templateMetaData.patterns());
                builder.field("order", templateMetaData.order());

                builder.startObject("settings");
                Settings settings = templateMetaData.settings();
                settings.toXContent(builder, params);
                builder.endObject();

                builder.startObject("mappings");
                for (ObjectObjectCursor<String, CompressedXContent> cursor1 : templateMetaData.mappings()) {
                    Map<String, Object> mapping = XContentHelper.convertToMap(new BytesArray(cursor1.value.uncompressed()), false).v2();
                    if (mapping.size() == 1 && mapping.containsKey(cursor1.key)) {
                        // the type name is the root value, reduce it
                        mapping = (Map<String, Object>) mapping.get(cursor1.key);
                    }
                    builder.field(cursor1.key);
                    builder.map(mapping);
                }
                builder.endObject();

                builder.endObject();
            }
            builder.endObject();

            builder.startObject("indices");
            for (IndexMetaData indexMetaData : metaData()) {
                builder.startObject(indexMetaData.getIndex().getName());

                builder.field("state", indexMetaData.getState().toString().toLowerCase(Locale.ENGLISH));

                builder.startObject("settings");
                Settings settings = indexMetaData.getSettings();
                settings.toXContent(builder, params);
                builder.endObject();

                builder.startObject("mappings");
                for (ObjectObjectCursor<String, MappingMetaData> cursor : indexMetaData.getMappings()) {
                    Map<String, Object> mapping = XContentHelper
                            .convertToMap(new BytesArray(cursor.value.source().uncompressed()), false).v2();
                    if (mapping.size() == 1 && mapping.containsKey(cursor.key)) {
                        // the type name is the root value, reduce it
                        mapping = (Map<String, Object>) mapping.get(cursor.key);
                    }
                    builder.field(cursor.key);
                    builder.map(mapping);
                }
                builder.endObject();

                builder.startArray("aliases");
                for (ObjectCursor<String> cursor : indexMetaData.getAliases().keys()) {
                    builder.value(cursor.value);
                }
                builder.endArray();

                builder.startObject(IndexMetaData.KEY_PRIMARY_TERMS);
                for (int shard = 0; shard < indexMetaData.getNumberOfShards(); shard++) {
                    builder.field(Integer.toString(shard), indexMetaData.primaryTerm(shard));
                }
                builder.endObject();

                builder.startObject(IndexMetaData.KEY_IN_SYNC_ALLOCATIONS);
                for (IntObjectCursor<Set<String>> cursor : indexMetaData.getInSyncAllocationIds()) {
                    builder.startArray(String.valueOf(cursor.key));
                    for (String allocationId : cursor.value) {
                        builder.value(allocationId);
                    }
                    builder.endArray();
                }
                builder.endObject();

                // index metadata
                builder.endObject();
            }
            builder.endObject();

            for (ObjectObjectCursor<String, MetaData.Custom> cursor : metaData.customs()) {
                builder.startObject(cursor.key);
                cursor.value.toXContent(builder, params);
                builder.endObject();
            }

            builder.endObject();
        }

        // routing table
        if (metrics.contains(Metric.ROUTING_TABLE)) {
            builder.startObject("routing_table");
            builder.startObject("indices");
            for (IndexRoutingTable indexRoutingTable : routingTable()) {
                builder.startObject(indexRoutingTable.getIndex().getName());
                builder.startObject("shards");
                for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
                    builder.startArray(Integer.toString(indexShardRoutingTable.shardId().id()));
                    for (ShardRouting shardRouting : indexShardRoutingTable) {
                        shardRouting.toXContent(builder, params);
                    }
                    builder.endArray();
                }
                builder.endObject();
                builder.endObject();
            }
            builder.endObject();
            builder.endObject();
        }

        // routing nodes
        if (metrics.contains(Metric.ROUTING_NODES)) {
            builder.startObject("routing_nodes");
            builder.startArray("unassigned");
            for (ShardRouting shardRouting : getRoutingNodes().unassigned()) {
                shardRouting.toXContent(builder, params);
            }
            builder.endArray();

            builder.startObject("nodes");
            for (RoutingNode routingNode : getRoutingNodes()) {
                builder.startArray(routingNode.nodeId() == null ? "null" : routingNode.nodeId());
                for (ShardRouting shardRouting : routingNode) {
                    shardRouting.toXContent(builder, params);
                }
                builder.endArray();
            }
            builder.endObject();

            builder.endObject();
        }
        if (metrics.contains(Metric.CUSTOMS)) {
            for (ObjectObjectCursor<String, Custom> cursor : customs) {
                builder.startObject(cursor.key);
                cursor.value.toXContent(builder, params);
                builder.endObject();
            }
        }

        return builder;
    }

    public static Builder builder(ClusterName clusterName) {
        return new Builder(clusterName);
    }

    public static Builder builder(ClusterState state) {
        return new Builder(state);
    }

    public static class Builder {

        private final ClusterName clusterName;
        private long version = 0;
        private String uuid = UNKNOWN_UUID;
        private MetaData metaData = MetaData.EMPTY_META_DATA;
        private RoutingTable routingTable = RoutingTable.EMPTY_ROUTING_TABLE;
        private DiscoveryNodes nodes = DiscoveryNodes.EMPTY_NODES;
        private ClusterBlocks blocks = ClusterBlocks.EMPTY_CLUSTER_BLOCK;
        private final ImmutableOpenMap.Builder<String, Custom> customs;
        private boolean fromDiff;
        private int minimumMasterNodesOnPublishingMaster = -1;

        public Builder(ClusterState state) {
            this.clusterName = state.clusterName;
            this.version = state.version();
            this.uuid = state.stateUUID();
            this.nodes = state.nodes();
            this.routingTable = state.routingTable();
            this.metaData = state.metaData();
            this.blocks = state.blocks();
            this.customs = ImmutableOpenMap.builder(state.customs());
            this.minimumMasterNodesOnPublishingMaster = state.minimumMasterNodesOnPublishingMaster;
            this.fromDiff = false;
        }

        public Builder(ClusterName clusterName) {
            customs = ImmutableOpenMap.builder();
            this.clusterName = clusterName;
        }

        public Builder nodes(DiscoveryNodes.Builder nodesBuilder) {
            return nodes(nodesBuilder.build());
        }

        public Builder nodes(DiscoveryNodes nodes) {
            this.nodes = nodes;
            return this;
        }

        public DiscoveryNodes nodes() {
            return nodes;
        }

        public Builder routingTable(RoutingTable routingTable) {
            this.routingTable = routingTable;
            return this;
        }

        public Builder metaData(MetaData.Builder metaDataBuilder) {
            return metaData(metaDataBuilder.build());
        }

        public Builder metaData(MetaData metaData) {
            this.metaData = metaData;
            return this;
        }

        public Builder blocks(ClusterBlocks.Builder blocksBuilder) {
            return blocks(blocksBuilder.build());
        }

        public Builder blocks(ClusterBlocks blocks) {
            this.blocks = blocks;
            return this;
        }

        public Builder version(long version) {
            this.version = version;
            return this;
        }

        public Builder incrementVersion() {
            this.version = versionGenerator.incrementAndGet();
            this.uuid = UNKNOWN_UUID;
            return this;
        }

        public Builder stateUUID(String uuid) {
            this.uuid = uuid;
            return this;
        }

        public Builder minimumMasterNodesOnPublishingMaster(int minimumMasterNodesOnPublishingMaster) {
            this.minimumMasterNodesOnPublishingMaster = minimumMasterNodesOnPublishingMaster;
            return this;
        }

        public Builder putCustom(String type, Custom custom) {
            customs.put(type, custom);
            return this;
        }

        public Builder removeCustom(String type) {
            customs.remove(type);
            return this;
        }

        public Builder customs(ImmutableOpenMap<String, Custom> customs) {
            this.customs.putAll(customs);
            return this;
        }

        public Builder fromDiff(boolean fromDiff) {
            this.fromDiff = fromDiff;
            return this;
        }

        public ClusterState build() {
            if (UNKNOWN_UUID.equals(uuid)) {
                uuid = UUIDs.randomBase64UUID();
            }
            return new ClusterState(clusterName, version, uuid, metaData, routingTable, nodes, blocks, customs.build(),
                minimumMasterNodesOnPublishingMaster, fromDiff);
        }

        public static byte[] toBytes(ClusterState state) throws IOException {
            BytesStreamOutput os = new BytesStreamOutput();
            state.writeTo(os);
            return BytesReference.toBytes(os.bytes());
        }

        /**
         * @param data      input bytes
         * @param localNode used to set the local node in the cluster state.
         */
        public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode, NamedWriteableRegistry registry) throws IOException {
            StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(data), registry);
            return readFrom(in, localNode);

        }
    }

    @Override
    public Diff<ClusterState> diff(ClusterState previousState) {
        return new ClusterStateDiff(previousState, this);
    }

    public static Diff<ClusterState> readDiffFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
        return new ClusterStateDiff(in, localNode);
    }

    public static ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
        ClusterName clusterName = new ClusterName(in);
        Builder builder = new Builder(clusterName);
        builder.version = in.readLong();
        builder.uuid = in.readString();
        builder.metaData = MetaData.readFrom(in);
        builder.routingTable = RoutingTable.readFrom(in);
        builder.nodes = DiscoveryNodes.readFrom(in, localNode);
        builder.blocks = new ClusterBlocks(in);
        int customSize = in.readVInt();
        for (int i = 0; i < customSize; i++) {
            Custom customIndexMetaData = in.readNamedWriteable(Custom.class);
            builder.putCustom(customIndexMetaData.getWriteableName(), customIndexMetaData);
        }
        builder.minimumMasterNodesOnPublishingMaster = in.getVersion().onOrAfter(Version.V_6_7_0) ? in.readVInt() : -1;
        return builder.build();
    }

    public static Diff<ClusterState> diff(ClusterState before, ClusterState after) {
        return new ClusterStateDiff(before, after);
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        clusterName.writeTo(out);
        out.writeLong(version);
        out.writeString(stateUUID);
        metaData.writeTo(out);
        routingTable.writeTo(out);
        nodes.writeTo(out);
        blocks.writeTo(out);
        // filter out custom states not supported by the other node
        int numberOfCustoms = 0;
        for (final ObjectCursor<Custom> cursor : customs.values()) {
            if (FeatureAware.shouldSerialize(out, cursor.value)) {
                numberOfCustoms++;
            }
        }
        out.writeVInt(numberOfCustoms);
        for (final ObjectCursor<Custom> cursor : customs.values()) {
            if (FeatureAware.shouldSerialize(out, cursor.value)) {
                out.writeNamedWriteable(cursor.value);
            }
        }
        if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
            out.writeVInt(minimumMasterNodesOnPublishingMaster);
        }
    }

    private static class ClusterStateDiff implements Diff<ClusterState> {

        private final long toVersion;

        private final String fromUuid;

        private final String toUuid;

        private final ClusterName clusterName;

        private final Diff<RoutingTable> routingTable;

        private final Diff<DiscoveryNodes> nodes;

        private final Diff<MetaData> metaData;

        private final Diff<ClusterBlocks> blocks;

        private final Diff<ImmutableOpenMap<String, Custom>> customs;

        private final int minimumMasterNodesOnPublishingMaster;

        ClusterStateDiff(ClusterState before, ClusterState after) {
            fromUuid = before.stateUUID;
            toUuid = after.stateUUID;
            toVersion = after.version;
            clusterName = after.clusterName;
            routingTable = after.routingTable.diff(before.routingTable);
            nodes = after.nodes.diff(before.nodes);
            metaData = after.metaData.diff(before.metaData);
            blocks = after.blocks.diff(before.blocks);
            customs = DiffableUtils.diff(before.customs, after.customs, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER);
            minimumMasterNodesOnPublishingMaster = after.minimumMasterNodesOnPublishingMaster;
        }

        ClusterStateDiff(StreamInput in, DiscoveryNode localNode) throws IOException {
            clusterName = new ClusterName(in);
            fromUuid = in.readString();
            toUuid = in.readString();
            toVersion = in.readLong();
            routingTable = RoutingTable.readDiffFrom(in);
            nodes = DiscoveryNodes.readDiffFrom(in, localNode);
            metaData = MetaData.readDiffFrom(in);
            blocks = ClusterBlocks.readDiffFrom(in);
            customs = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER);
            minimumMasterNodesOnPublishingMaster = in.getVersion().onOrAfter(Version.V_6_7_0) ? in.readVInt() : -1;
        }

        @Override
        public void writeTo(StreamOutput out) throws IOException {
            clusterName.writeTo(out);
            out.writeString(fromUuid);
            out.writeString(toUuid);
            out.writeLong(toVersion);
            routingTable.writeTo(out);
            nodes.writeTo(out);
            metaData.writeTo(out);
            blocks.writeTo(out);
            customs.writeTo(out);
            if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
                out.writeVInt(minimumMasterNodesOnPublishingMaster);
            }
        }

        @Override
        public ClusterState apply(ClusterState state) {
            Builder builder = new Builder(clusterName);
            if (toUuid.equals(state.stateUUID)) {
                // no need to read the rest - cluster state didn't change
                return state;
            }
            if (fromUuid.equals(state.stateUUID) == false) {
                throw new IncompatibleClusterStateVersionException(state.version, state.stateUUID, toVersion, fromUuid);
            }
            builder.stateUUID(toUuid);
            builder.version(toVersion);
            builder.routingTable(routingTable.apply(state.routingTable));
            builder.nodes(nodes.apply(state.nodes));
            builder.metaData(metaData.apply(state.metaData));
            builder.blocks(blocks.apply(state.blocks));
            builder.customs(customs.apply(state.customs));
            builder.minimumMasterNodesOnPublishingMaster(minimumMasterNodesOnPublishingMaster);
            builder.fromDiff(true);
            return builder.build();
        }

    }

}


text:
<?php

namespace Google\AdsApi\AdManager\v202205;

/**
 * This file was generated from WSDL. DO NOT EDIT.
 */
class ProgrammaticCreativeSource
{
    const PUBLISHER = 'PUBLISHER';
    const ADVERTISER = 'ADVERTISER';
    const UNKNOWN = 'UNKNOWN';

}


text:
namespace eosio { namespace chain { namespace eosvmoc {

using namespace boost::asio;

static size_t get_size_of_fd(int fd) {
   struct stat st;
   FC_ASSERT(fstat(fd, &st) == 0, "failed to get size of fd");
   return st.st_size;
}

static void copy_memfd_contents_to_pointer(void* dst, int fd) {
   struct stat st;
   FC_ASSERT(fstat(fd, &st) == 0, "failed to get size of fd");
   if(st.st_size == 0)
      return;
   void* contents = mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
   FC_ASSERT(contents != MAP_FAILED, "failed to map memfd file");
   memcpy(dst, contents, st.st_size);
   munmap(contents, st.st_size);
}

struct compile_monitor_session {
   compile_monitor_session(boost::asio::io_context& context, local::datagram_protocol::socket&& n, wrapped_fd&& c, wrapped_fd& t) :
      _ctx(context),
      _nodeos_instance_socket(std::move(n)),
      _cache_fd(std::move(c)),
      _trampoline_socket(t) {

      struct stat st;
      FC_ASSERT(fstat(_cache_fd, &st) == 0, "failed to stat cache fd");
      _code_size = st.st_size;
      _code_mapping = (char*)mmap(nullptr, _code_size, PROT_READ|PROT_WRITE, MAP_SHARED, _cache_fd, 0);
      FC_ASSERT(_code_mapping != MAP_FAILED, "failed to mmap cache file");
      _allocator = reinterpret_cast<allocator_t*>(_code_mapping);

      read_message_from_nodeos();
   }

   ~compile_monitor_session() {
      munmap(_code_mapping, _code_size);
   }

   void read_message_from_nodeos() {
      _nodeos_instance_socket.async_wait(local::datagram_protocol::socket::wait_read, [this](auto ec) {
         if(ec) {
            connection_dead_signal();
            return;
         }
         auto [success, message, fds] = read_message_with_fds(_nodeos_instance_socket);
         if(!success) {
            connection_dead_signal();
            return;
         }
         std::visit(overloaded {
            [&, &fds=fds](const compile_wasm_message& compile) {
               if(fds.size() != 1) {
                  connection_dead_signal();
                  return;
               }
               kick_compile_off(compile.code, std::move(fds[0]));
            },
            [&](const evict_wasms_message& evict) {
               for(const code_descriptor& cd : evict.codes) {
                  _allocator->deallocate(_code_mapping + cd.code_begin);
                  _allocator->deallocate(_code_mapping + cd.initdata_begin);
               }
            },
            [&](const auto&) {
               //anything else is an error
               connection_dead_signal();
               return;
            }
         }, message);

         read_message_from_nodeos();
      });
   }

   void kick_compile_off(const code_tuple& code_id, wrapped_fd&& wasm_code) {
      //prepare a requst to go out to the trampoline
      int socks[2];
      socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, socks);
      local::datagram_protocol::socket response_socket(_ctx);
      response_socket.assign(local::datagram_protocol(), socks[0]);
      std::vector<wrapped_fd> fds_pass_to_trampoline;
      fds_pass_to_trampoline.emplace_back(socks[1]);
      fds_pass_to_trampoline.emplace_back(std::move(wasm_code));

      eosvmoc_message trampoline_compile_request = compile_wasm_message{code_id};
      if(write_message_with_fds(_trampoline_socket, trampoline_compile_request, fds_pass_to_trampoline) == false) {
         wasm_compilation_result_message reply{code_id, compilation_result_unknownfailure{}, _allocator->get_free_memory()};
         write_message_with_fds(_nodeos_instance_socket, reply);
         return;
      }

      current_compiles.emplace_front(code_id, std::move(response_socket));
      read_message_from_compile_task(current_compiles.begin());
   }

   void read_message_from_compile_task(std::list<std::tuple<code_tuple, local::datagram_protocol::socket>>::iterator current_compile_it) {
      auto& [code, socket] = *current_compile_it;
      socket.async_wait(local::datagram_protocol::socket::wait_read, [this, current_compile_it](auto ec) {
         //at this point we only expect 1 of 2 things to happen: we either get a reply (success), or we get no reply (failure)
         auto& [code, socket] = *current_compile_it;
         auto [success, message, fds] = read_message_with_fds(socket);

         wasm_compilation_result_message reply{code, compilation_result_unknownfailure{}, _allocator->get_free_memory()};

         void* code_ptr = nullptr;
         void* mem_ptr = nullptr;
         try {
            if(success && std::holds_alternative<code_compilation_result_message>(message) && fds.size() == 2) {
               code_compilation_result_message& result = std::get<code_compilation_result_message>(message);
               code_ptr = _allocator->allocate(get_size_of_fd(fds[0]));
               mem_ptr = _allocator->allocate(get_size_of_fd(fds[1]));

               if(code_ptr == nullptr || mem_ptr == nullptr) {
                  _allocator->deallocate(code_ptr);
                  _allocator->deallocate(mem_ptr);
                  reply.result = compilation_result_toofull();
               }
               else {
                  copy_memfd_contents_to_pointer(code_ptr, fds[0]);
                  copy_memfd_contents_to_pointer(mem_ptr, fds[1]);

                  reply.result = code_descriptor {
                     code.code_id,
                     code.vm_version,
                     0,
                     (uintptr_t)code_ptr - (uintptr_t)_code_mapping,
                     result.start,
                     result.apply_offset,
                     result.starting_memory_pages,
                     (uintptr_t)mem_ptr - (uintptr_t)_code_mapping,
                     (unsigned)get_size_of_fd(fds[1]),
                     result.initdata_prologue_size
                  };
               }
            }
         }
         catch(...) {
            _allocator->deallocate(code_ptr);
            _allocator->deallocate(mem_ptr);
         }

         write_message_with_fds(_nodeos_instance_socket, reply);

         //either way, we are done
         _ctx.post([this, current_compile_it]() {
            current_compiles.erase(current_compile_it);
         });
      });

   }

   boost::signals2::signal<void()> connection_dead_signal;

private:
   boost::asio::io_context& _ctx;
   local::datagram_protocol::socket _nodeos_instance_socket;
   wrapped_fd  _cache_fd;
   wrapped_fd& _trampoline_socket;

   char* _code_mapping;
   size_t _code_size;
   allocator_t* _allocator;

   std::list<std::tuple<code_tuple, local::datagram_protocol::socket>> current_compiles;
};

struct compile_monitor {
   compile_monitor(boost::asio::io_context& ctx, local::datagram_protocol::socket&& n, wrapped_fd&& t) : _nodeos_socket(std::move(n)), _trampoline_socket(std::move(t)) {
      //the only duty of compile_monitor is to create a compile_monitor_session when a code_cache instance
      // in nodeos wants one
      wait_for_new_incomming_session(ctx);
   }

   void wait_for_new_incomming_session(boost::asio::io_context& ctx) {
      _nodeos_socket.async_wait(boost::asio::local::datagram_protocol::socket::wait_read, [this, &ctx](auto ec) {
         if(ec) {
            ctx.stop();
            return;
         }
         auto [success, message, fds] = read_message_with_fds(_nodeos_socket);
         if(!success) {   //failure reading indicates that nodeos has shut down
            ctx.stop();
            return;
         }
         if(!std::holds_alternative<initialize_message>(message) || fds.size() != 2) {
            ctx.stop();
            return;
         }
         try {
            local::datagram_protocol::socket _socket_for_comm(ctx);
            _socket_for_comm.assign(local::datagram_protocol(), fds[0].release());
            _compile_sessions.emplace_front(ctx, std::move(_socket_for_comm), std::move(fds[1]), _trampoline_socket);
            _compile_sessions.front().connection_dead_signal.connect([&, it = _compile_sessions.begin()]() {
               ctx.post([&]() {
                  _compile_sessions.erase(it);
               });
            });
            write_message_with_fds(_nodeos_socket, initalize_response_message());
         }
         catch(const std::exception& e) {
            write_message_with_fds(_nodeos_socket, initalize_response_message{e.what()});
         }
         catch(...) {
            write_message_with_fds(_nodeos_socket, initalize_response_message{"Failed to create compile process"});
         }

         wait_for_new_incomming_session(ctx);
      });
   }

   local::datagram_protocol::socket _nodeos_socket;
   wrapped_fd _trampoline_socket;

   std::list<compile_monitor_session> _compile_sessions;
};

void launch_compile_monitor(int nodeos_fd) {
   prctl(PR_SET_NAME, "oc-monitor");
   prctl(PR_SET_PDEATHSIG, SIGKILL);

   //first off, let's disable shutdown signals to us; we want all shutdown indicators to come from
   // nodeos shutting us down
   sigset_t set;
   sigemptyset(&set);
   sigaddset(&set, SIGHUP);
   sigaddset(&set, SIGTERM);
   sigaddset(&set, SIGPIPE);
   sigaddset(&set, SIGINT);
   sigaddset(&set, SIGQUIT);
   sigprocmask(SIG_BLOCK, &set, nullptr);

   struct sigaction sa;
   sa.sa_handler =  SIG_DFL;
   sa.sa_flags = SA_NOCLDWAIT;
   sigaction(SIGCHLD, &sa, nullptr);

   int socks[2]; //0: local trampoline socket, 1: the one we give to trampoline
   socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, socks);
   pid_t child = fork();
   if(child == 0) {
      close(socks[0]);
      run_compile_trampoline(socks[1]);
   }
   close(socks[1]);

   {
      boost::asio::io_context ctx;
      boost::asio::local::datagram_protocol::socket nodeos_socket(ctx);
      nodeos_socket.assign(boost::asio::local::datagram_protocol(), nodeos_fd);
      wrapped_fd trampoline_socket(socks[0]);
      compile_monitor monitor(ctx, std::move(nodeos_socket), std::move(trampoline_socket));
      ctx.run();
      if(monitor._compile_sessions.size())
         std::cerr << "ERROR: EOS VM OC compiler monitor exiting with active sessions" << std::endl;
   }

   _exit(0);
}

struct compile_monitor_trampoline {
   void start() {
      //create communication socket; let's hold off on asio usage until all forks are done
      int socks[2];
      socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, socks);
      compile_manager_fd = socks[0];

      compile_manager_pid = fork();
      if(compile_manager_pid == 0) {
         close(socks[0]);
         launch_compile_monitor(socks[1]);
      }
      close(socks[1]);
   }

   pid_t compile_manager_pid = -1;
   int compile_manager_fd = -1;
};

static compile_monitor_trampoline the_compile_monitor_trampoline;
extern "C" int __real_main(int, char*[]);
extern "C" int __wrap_main(int argc, char* argv[]) {

   the_compile_monitor_trampoline.start();
   return __real_main(argc, argv);
}

wrapped_fd get_connection_to_compile_monitor(int cache_fd) {
   FC_ASSERT(the_compile_monitor_trampoline.compile_manager_pid >= 0, "EOS VM oop connection doesn't look active");

   int socks[2]; //0: our socket to compile_manager_session, 1: socket we'll give to compile_maanger_session
   socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, socks);
   wrapped_fd socket_to_monitor_session(socks[0]);
   wrapped_fd socket_to_hand_to_monitor_session(socks[1]);

   //we don't own cache_fd, so try to be extra careful not to accidentally close it: don't stick it in a wrapped_fd
   // to hand off to write_message_with_fds even temporarily. make a copy of it.
   int dup_of_cache_fd = dup(cache_fd);
   FC_ASSERT(dup_of_cache_fd != -1, "failed to dup cache_fd");
   wrapped_fd dup_cache_fd(dup_of_cache_fd);

   std::vector<wrapped_fd> fds_to_pass;
   fds_to_pass.emplace_back(std::move(socket_to_hand_to_monitor_session));
   fds_to_pass.emplace_back(std::move(dup_cache_fd));
   write_message_with_fds(the_compile_monitor_trampoline.compile_manager_fd, initialize_message(), fds_to_pass);

   auto [success, message, fds] = read_message_with_fds(the_compile_monitor_trampoline.compile_manager_fd);
   EOS_ASSERT(success, misc_exception, "failed to read response from monitor process");
   EOS_ASSERT(std::holds_alternative<initalize_response_message>(message), misc_exception, "unexpected response from monitor process");
   EOS_ASSERT(!std::get<initalize_response_message>(message).error_message, misc_exception, "Error message from monitor process: ${e}", ("e", *std::get<initalize_response_message>(message).error_message));
   return socket_to_monitor_session;
}

}}}


text:
class Api::ServerController < Api::ApiController
  def info
    @base_url = system_environment.getBaseUrlForShine()
    @base_ssl_url = system_environment.getBaseSslUrlForShine()
    @artifacts_dir = go_config_service.artifactsDir().getAbsolutePath()
    @shine_db_path = system_environment.shineDb().getAbsolutePath()
    @config_dir = system_environment.configDir().getAbsolutePath()
  end

  def capture_support_info
    information = server_status_service.captureServerInfo(current_user, result = HttpLocalizedOperationResult.new)
    if !result.isSuccessful()
      render_localized_operation_result result && return
    end

    send_data information, disposition: "inline", stream: false, type: "text"
  end
end


text:
export default {
	name: 'SiteHeader',
};