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

package com.twitter.heron.uploader.s3;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.Protocol;
import com.amazonaws.SdkClientException;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;

import com.google.common.base.Strings;

import com.twitter.heron.spi.common.Config;
import com.twitter.heron.spi.common.Context;
import com.twitter.heron.spi.uploader.IUploader;
import com.twitter.heron.spi.uploader.UploaderException;

/**
 * Provides a basic uploader class for uploading topology packages to s3.
 *

 * By default this uploader will write topology packages to s3://<bucket>/<topologyName>/topology.tar.gz
 * trying to obtain credentials using the default credential provider chain. The package destination serves as known
 * location which can be used to download the topology package in order to run the topology.
 *

 * This class also handles the undo action by copying any existing topology.tar.gz package found in the folder to
 * previous_topology.tar.gz. In the event that the deploy fails and the undo action is triggered the previous_topology.tar.gz
 * file will be renamed to topology.tar.gz effectively rolling back the live code. In the event that the deploy is successful
 * the previous_topology.tar.gz package will be deleted as it is no longer needed.
 *

 * The config values for this uploader are:
 * heron.class.uploader (required) com.twitter.heron.uploader.s3.S3Uploader
 * heron.uploader.s3.bucket (required) The bucket that you have write access to where you want the topology packages to be stored
 * heron.uploader.s3.path_prefix (optional) Optional prefix for the path to the topology packages
 * heron.uploader.s3.access_key (optional) S3 access key that can be used to write to the bucket provided
 * heron.uploader.s3.secret_key (optional) S3 access secret that can be used to write to the bucket provided
 * heron.uploader.s3.aws_profile (optional) AWS profile to use
 */
public class S3Uploader implements IUploader {
  private static final Logger LOG = Logger.getLogger(S3Uploader.class.getName());

  private String bucket;
  protected AmazonS3 s3Client;
  private String remoteFilePath;

  // The path prefix will be prepended to the path inside the provided bucket.
  // For example if you set bucket=foo and path_prefix=some/sub/folder then you
  // can expect the final path in s3 to look like:
  // s3://foo/some/sub/folder/<topologyName>/topology.tar.gz
  private String pathPrefix;

  // Stores the path to the backup version of the topology in case the deploy fails and
  // it needs to be undone. This is the same as the existing path but prepended with `previous_`.
  // This serves as a simple backup incase we need to revert.
  private String previousVersionFilePath;

  private File packageFileHandler;

  @Override
  public void initialize(Config config) {
    bucket = S3Context.bucket(config);
    String accessKey = S3Context.accessKey(config);
    String accessSecret = S3Context.secretKey(config);
    String awsProfile = S3Context.awsProfile(config);
    String proxy = S3Context.proxyUri(config);
    String endpoint = S3Context.uri(config);
    String customRegion = S3Context.region(config);
    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();

    if (Strings.isNullOrEmpty(bucket)) {
      throw new RuntimeException("Missing heron.uploader.s3.bucket config value");
    }

    // If an accessKey is specified, use it. Otherwise check if an aws profile
    // is specified. If neither was set just use the DefaultAWSCredentialsProviderChain
    // by not specifying a CredentialsProvider.
    if (!Strings.isNullOrEmpty(accessKey) || !Strings.isNullOrEmpty(accessSecret)) {

      if (!Strings.isNullOrEmpty(awsProfile)) {
        throw new RuntimeException("Please provide access_key/secret_key "
            + "or aws_profile, not both.");
      }

      if (Strings.isNullOrEmpty(accessKey)) {
        throw new RuntimeException("Missing heron.uploader.s3.access_key config value");
      }

      if (Strings.isNullOrEmpty(accessSecret)) {
        throw new RuntimeException("Missing heron.uploader.s3.secret_key config value");
      }
      builder.setCredentials(
              new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, accessSecret))
      );
    } else if (!Strings.isNullOrEmpty(awsProfile)) {
      builder.setCredentials(new ProfileCredentialsProvider(awsProfile));
    }

    if (!Strings.isNullOrEmpty(proxy)) {
      URI proxyUri;

      try  {
        proxyUri = new URI(proxy);
      } catch (URISyntaxException e) {
        throw new RuntimeException("Invalid heron.uploader.s3.proxy_uri config value: " + proxy, e);
      }

      ClientConfiguration clientCfg = new ClientConfiguration();
      clientCfg.withProtocol(Protocol.HTTPS)
              .withProxyHost(proxyUri.getHost())
              .withProxyPort(proxyUri.getPort());

      if (!Strings.isNullOrEmpty(proxyUri.getUserInfo())) {
        String[] info = proxyUri.getUserInfo().split(":", 2);
        clientCfg.setProxyUsername(info[0]);
        if (info.length > 1) {
          clientCfg.setProxyPassword(info[1]);
        }
      }

      builder.setClientConfiguration(clientCfg);
    }

    s3Client = builder.withRegion(customRegion)
            .withPathStyleAccessEnabled(true)
            .withChunkedEncodingDisabled(true)
            .withPayloadSigningEnabled(true)
            .build();

    if (!Strings.isNullOrEmpty(endpoint)) {
      s3Client.setEndpoint(endpoint);
    }

    final String topologyName = Context.topologyName(config);
    final String topologyPackageLocation = Context.topologyPackageFile(config);

    pathPrefix = S3Context.pathPrefix(config);
    packageFileHandler = new File(topologyPackageLocation);

    // The path the packaged topology will be uploaded to
    remoteFilePath = generateS3Path(pathPrefix, topologyName, packageFileHandler.getName());

    // Generate the location of the backup file incase we need to revert the deploy
    previousVersionFilePath = generateS3Path(pathPrefix, topologyName,
        "previous_" + packageFileHandler.getName());
  }

  @Override
  public URI uploadPackage() throws UploaderException {
    // Backup any existing files incase we need to undo this action
    if (s3Client.doesObjectExist(bucket, remoteFilePath)) {
      s3Client.copyObject(bucket, remoteFilePath, bucket, previousVersionFilePath);
    }

    // Attempt to write the topology package to s3
    try {
      s3Client.putObject(bucket, remoteFilePath, packageFileHandler);
    } catch (SdkClientException e) {
      throw new UploaderException(
          String.format("Error writing topology package to %s %s", bucket, remoteFilePath), e);
    }

    // Ask s3 for the url to the topology package we just uploaded
    final URL resourceUrl = s3Client.getUrl(bucket, remoteFilePath);
    LOG.log(Level.INFO, "Package URL: {0}", resourceUrl);

    // This will happen if the package does not actually exist in the place where we uploaded it to.
    if (resourceUrl == null) {
      throw new UploaderException(
          String.format("Resource not found for bucket %s and path %s", bucket, remoteFilePath));
    }

    try {
      return resourceUrl.toURI();
    } catch (URISyntaxException e) {
      throw new UploaderException(
          String.format("Could not convert URL %s to URI", resourceUrl), e);
    }
  }

  /**
   * Generate the path to a file in s3 given a prefix, topologyName, and filename
   *
   * @param pathPrefixParent designates any parent folders that should be prefixed to the resulting path
   * @param topologyName the name of the topology that we are uploaded
   * @param filename the name of the resulting file that is going to be uploaded
   * @return the full path of the package under the bucket. The bucket is not included in this path as it is a separate
   * argument that is passed to the putObject call in the s3 sdk.
   */
  private String generateS3Path(String pathPrefixParent, String topologyName, String filename) {
    List<String> pathParts = new ArrayList<>(Arrays.asList(pathPrefixParent.split("/")));
    pathParts.add(topologyName);
    pathParts.add(filename);

    return String.join("/", pathParts);
  }

  @Override
  public boolean undo() {
    // Check if there is a previous version. This will not be true on the first deploy.
    if (s3Client.doesObjectExist(bucket, previousVersionFilePath)) {
      try {
        // Restore the previous version of the topology
        s3Client.copyObject(bucket, previousVersionFilePath, bucket, remoteFilePath);
      } catch (SdkClientException e) {
        LOG.log(Level.SEVERE, "Reverting to previous topology version failed", e);
        return false;
      }
    }

    return true;
  }

  @Override
  public void close() {
    // Cleanup the backup file if it exists as its not needed anymore.
    // This will succeed whether the file exists or not.
    if (!Strings.isNullOrEmpty(previousVersionFilePath)) {
      s3Client.deleteObject(bucket, previousVersionFilePath);
    }
  }
}


text:
package org.seasar.doma.internal.apt.dao;

import org.seasar.doma.Dao;
import org.seasar.doma.Select;
import org.seasar.doma.Update;
import org.seasar.doma.jdbc.SelectOptions;

import example.entity.Emp;

/**
 * @author taedium
 *
 */
@Dao(config = MyConfig.class)
public interface NoConfigDaoExtendsDao extends NoConfigEmpDao {

    @Override
    @Select
    public Emp selectById(Integer id, SelectOptions options);

    @Update
    public int update2(Emp entity);
}

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Tuburcinia rodgersiae Miyabe ex S. Ito

### Remarks
null


text:
require "arty/version"
require "arty/connection"

module Arty
  # Your code goes here...
end


text:
@interface AddFriendViewController : HYViewController

@end


text:
namespace R3.UI
{
	using System;
	using System.ComponentModel;
	using System.Drawing.Design;
	using System.Windows.Forms;
	using System.Windows.Forms.Design;

	public class TrackBarValueEditor<Type> : UITypeEditor
	{
		private IWindowsFormsEditorService editorService = null;

		public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value )
		{
			if( context == null || provider == null )
				return value;

			editorService = (IWindowsFormsEditorService)provider.GetService( typeof( IWindowsFormsEditorService ) );
			if( editorService == null )
				return value;

			// Create a new trackbar and set it up.
			TrackBar trackBar = new TrackBar();
			trackBar.ValueChanged += new EventHandler( this.ValueChanged );
			trackBar.MouseLeave += new EventHandler( this.MouseLeave );

			// Get the low/high values.
			PropertyDescriptor prop = context.PropertyDescriptor;
			RangeAttribute ra = prop.Attributes[typeof( RangeAttribute )] as RangeAttribute;
			double valueLow = ra.Low;
			double valueHigh = ra.High;

			if( typeof( Type ) == typeof( int ) )
			{
				trackBar.Minimum = (int)valueLow;
				trackBar.Maximum = (int)valueHigh;
				trackBar.TickFrequency = 1;
				trackBar.Value = Convert.ToInt32( value );
				editorService.DropDownControl( trackBar );
				value = trackBar.Value;
				return value;
			}

			trackBar.Minimum = 0;
			trackBar.Maximum = 100;
			trackBar.TickStyle = TickStyle.None;

			// Set the corresponding trackbar value.
			double percent = ( Convert.ToDouble( value ) - valueLow ) / ( valueHigh - valueLow );
			trackBar.Value = (int)( 100 * percent );

			// Show the control.
			editorService.DropDownControl( trackBar );

			// Here is the output value.
			value = valueLow + ( (double)trackBar.Value / 100 ) * ( valueHigh - valueLow );
			return value;
		}

		public override UITypeEditorEditStyle GetEditStyle( ITypeDescriptorContext context )
		{
			if( context != null && context.Instance != null )
				return UITypeEditorEditStyle.DropDown;

			return base.GetEditStyle( context );
		}

		private void ValueChanged( object sender, EventArgs e )
		{
			// I couldn't figure out how to update the text here, but that would be nice.
		}

		private void MouseLeave( object sender, System.EventArgs e )
		{
			if( editorService != null )
				editorService.CloseDropDown();
		}
	}
}


text:
using System;

namespace OneCog.Io.Plex.Section
{
    public interface IShow : ISection
    {

    }

    internal class Show : IShow
    {
        public Guid Id { get; private set; }

        public string Key { get; private set; }
    }
}


text:
#include "postgres.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "utils/palloc.h"
#include "storage/fd.h"
#include "storage/relfilenode.h"

#include "catalog/catalog.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_database.h"
#include "catalog/gp_persistent.h"
#include "cdb/cdbsharedoidsearch.h"
#include "access/persistentfilesysobjname.h"
#include "cdb/cdbdirectopen.h"
#include "cdb/cdbpersistentstore.h"
#include "cdb/cdbpersistentfilesysobj.h"
#include "cdb/cdbpersistentdatabase.h"
#include "cdb/cdbpersistentrelation.h"
#include "storage/itemptr.h"
#include "utils/hsearch.h"
#include "storage/shmem.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/transam.h"
#include "utils/guc.h"
#include "storage/smgr.h"
#include "storage/ipc.h"
#include "utils/builtins.h"
#include "utils/faultinjector.h"

/*
 * This module is for generic relation file create and drop.
 *
 * For create, it makes the file-system create of an empty file fully transactional so
 * the relation file will be deleted even on system crash.  The relation file could be a heap,
 * index, or append-only (row- or column-store).
 */

typedef struct PersistentRelationSharedData
{

	PersistentFileSysObjSharedData		fileSysObjSharedData;

} PersistentRelationSharedData;

#define PersistentRelationData_StaticInit {PersistentFileSysObjData_StaticInit}

typedef struct PersistentRelationData
{

	PersistentFileSysObjData		fileSysObjData;

} PersistentRelationData;

/*
 * Global Variables
 */
PersistentRelationSharedData	*persistentRelationSharedData = NULL;

PersistentRelationData	persistentRelationData = PersistentRelationData_StaticInit;

static void PersistentRelation_VerifyInitScan(void)
{
	if (persistentRelationSharedData == NULL)
		elog(PANIC, "Persistent relation information shared-memory not setup");

	PersistentFileSysObj_VerifyInitScan();
}

// -----------------------------------------------------------------------------
// Helpers
// -----------------------------------------------------------------------------

extern void PersistentRelation_Reset(void)
{
	// Currently, nothing to do.
}

//------------------------------------------------------------------------------

int64 PersistentRelation_MyHighestSerialNum(void)
{
	return PersistentFileSysObj_MyHighestSerialNum(
							PersistentFsObjType_RelationFile);
}

int64 PersistentRelation_CurrentMaxSerialNum(void)
{
	READ_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	int64 value;

	READ_PERSISTENT_STATE_ORDERED_LOCK;

	value = PersistentFileSysObj_CurrentMaxSerialNum(
							PersistentFsObjType_RelationFile);

	READ_PERSISTENT_STATE_ORDERED_UNLOCK;

	return value;
}

static Oid persistentRelationCheckTablespace;
static int32 persistentRelationCheckTablespaceUseCount;
static RelFileNode persistentRelationCheckTablespaceRelFileNode;

static bool PersistentRelation_CheckTablespaceScanTupleCallback(
	ItemPointer 			persistentTid,
	int64					persistentSerialNum,
	Datum					*values)
{
	RelFileNode		relFileNode;
	int32			segmentFileNum;

	PersistentFileSysRelStorageMgr relationStorageManager;

	PersistentFileSysState	state;

	int64			createMirrorDataLossTrackingSessionNum;

	MirroredObjectExistenceState		mirrorExistenceState;

	MirroredRelDataSynchronizationState mirrorDataSynchronizationState;
	bool							mirrorBufpoolMarkedForScanIncrementalResync;
	int64							mirrorBufpoolResyncChangedPageCount;
	XLogRecPtr						mirrorBufpoolResyncCkptLoc;
	BlockNumber 					mirrorBufpoolResyncCkptBlockNum;

	int64					mirrorAppendOnlyLossEof;
	int64					mirrorAppendOnlyNewEof;

	PersistentFileSysRelBufpoolKind relBufpoolKind;

	TransactionId			parentXid;
	int64					serialNum;

	GpPersistentRelationNode_GetValues(
									values,
									&relFileNode.spcNode,
									&relFileNode.dbNode,
									&relFileNode.relNode,
									&segmentFileNum,
									&relationStorageManager,
									&state,
									&createMirrorDataLossTrackingSessionNum,
									&mirrorExistenceState,
									&mirrorDataSynchronizationState,
									&mirrorBufpoolMarkedForScanIncrementalResync,
									&mirrorBufpoolResyncChangedPageCount,
									&mirrorBufpoolResyncCkptLoc,
									&mirrorBufpoolResyncCkptBlockNum,
									&mirrorAppendOnlyLossEof,
									&mirrorAppendOnlyNewEof,
									&relBufpoolKind,
									&parentXid,
									&serialNum);

	if (state == PersistentFileSysState_Created &&
		relFileNode.spcNode == persistentRelationCheckTablespace)
	{
		persistentRelationCheckTablespaceUseCount++;
		if (persistentRelationCheckTablespaceUseCount == 1)
		{
			memcpy(&persistentRelationCheckTablespaceRelFileNode, &relFileNode, sizeof(RelFileNode));
		}
	}

	return true;	// Continue.
}

void PersistentRelation_CheckTablespace(
	Oid				tablespace,

	int32			*useCount,

	RelFileNode		*exampleRelFileNode)
{
	persistentRelationCheckTablespace = tablespace;
	persistentRelationCheckTablespaceUseCount = 0;

	MemSet(&persistentRelationCheckTablespaceRelFileNode, 0, sizeof(RelFileNode));

	PersistentFileSysObj_Scan(
		PersistentFsObjType_RelationFile,
		PersistentRelation_CheckTablespaceScanTupleCallback);

	*useCount = persistentRelationCheckTablespaceUseCount;
	memcpy(exampleRelFileNode, &persistentRelationCheckTablespaceRelFileNode, sizeof(RelFileNode));
}

// -----------------------------------------------------------------------------
// State Change
// -----------------------------------------------------------------------------

/*
 * Indicate we intend to create a relation file as part of the current transaction.
 *
 * This function adds an entry in 'gp_persistent_relation_node' for either a new table (segment file
 * # 0) or a new segment file under AO table (segment file # > 0 for row/column-oriented AO) with a state
 * 'Create Pending'. An XLOG IntentToCreate record is generated that will guard the subsequent file-system
 * create in case the transaction aborts.
 *
 * Paramaters
 * -----------
 * relFileNode = The tablespace, database, and relation OIDs for the create
 * segmentFileNum = As the name implies (   0 for heap
 *                                       >= 0 for RO/CO AO as applicable)
 * relStorageMgr = Persistent Relation storage Manager
 * relBufpoolKind = Buffer pool type beneath corrosponding relation
 * TODO bufferPollBulkLoad = ???
 * TODO mirrorExistenceState = ???
 * TODO relDataSynchronizationState = ???
 * flushToXlog = If true, the XLOG record for this change will be flushed to disk.
 * TODO isLocalBuf = ???
 *
 * Return
 * ------
 * relationName = Name of the relation used for either debugging or to store in PendingDelete LL.
 * persistentTid = Resulting TID of the gp_persistent_rel_files tuple for the relation
 * serialNum = Resulting serial number for the relation.  Distinquishes the uses of the tuple
 */
void PersistentRelation_AddCreatePending(
	RelFileNode 		*relFileNode,
	int32				segmentFileNum,
	PersistentFileSysRelStorageMgr relStorageMgr,
	PersistentFileSysRelBufpoolKind relBufpoolKind,
	bool				bufferPoolBulkLoad,
	MirroredObjectExistenceState mirrorExistenceState,
	MirroredRelDataSynchronizationState relDataSynchronizationState,
	char				*relationName,
	ItemPointer			persistentTid,
	int64				*serialNum,
	bool 				flushToXLog,
	bool				isLocalBuf)
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;
	TransactionId topXid;

	XLogRecPtr mirrorBufpoolResyncCkptLoc;

	Datum values[Natts_gp_persistent_relation_node];

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	MemSet(&mirrorBufpoolResyncCkptLoc, 0, sizeof(XLogRecPtr));

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		MemSet(persistentTid, 0, sizeof(ItemPointerData));
		*serialNum = 0;

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	/* Verify if the needed shared mem data structures for persistent tables are setup and inited */
	PersistentRelation_VerifyInitScan();

	/* Setup the file system object name */
	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	topXid = GetTopTransactionId();

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	/* Create a values array which will be used to create a 'gp_persistent_relation_node' tuple */
	GpPersistentRelationNode_SetDatumValues(
										values,
										relFileNode->spcNode,
										relFileNode->dbNode,
										relFileNode->relNode,
										segmentFileNum,
										relStorageMgr,
										(bufferPoolBulkLoad ?
												PersistentFileSysState_BulkLoadCreatePending :
												PersistentFileSysState_CreatePending),
										/* createMirrorDataLossTrackingSessionNum */ 0,
										mirrorExistenceState,
										relDataSynchronizationState,
										/* mirrorBufpoolMarkedForScanIncrementalResync */ false,
										/* mirrorBufpoolResyncChangedPageCount */ 0,
										&mirrorBufpoolResyncCkptLoc,
										/* mirrorBufpoolResyncCkptBlockNum */ 0,
										/* mirrorAppendOnlyLossEof */ 0,
										/* mirrorAppendOnlyNewEof */ 0,
										relBufpoolKind,
										topXid,
										/* persistentSerialNum */ 0);	// This will be set by PersistentFileSysObj_AddTuple.

	/* Add a new tuple to 'gp_persistent_relation_node' table for the new relation/segment file
	 * we intend to create. This will also create and apply a new persistent serial number. */
	PersistentFileSysObj_AddTuple(
							PersistentFsObjType_RelationFile,
							values,
							flushToXLog,
							persistentTid,
							serialNum);

	/*
	 * This XLOG must be generated under the persistent write-lock.
	 */
#ifdef MASTER_MIRROR_SYNC
	mmxlog_log_create_relfilenode(
						relFileNode->spcNode,
						relFileNode->dbNode,
						relFileNode->relNode,
						segmentFileNum);
#endif

	SIMPLE_FAULT_INJECTOR(FaultBeforePendingDeleteRelationEntry);

   /* We'll add an entry to the PendingDelete LinkedList (LL) to remeber what we
    * created in this transaction (or sub-transaction). If the transaction
    * aborts then we can search for all such entries in this LL and get rid of (delete)
    * such relations or segment files on the disk.
	*
	* MPP-18228
	* To make adding 'Create Pending' entry to persistent table and adding
	* to the PendingDelete list atomic
	*/
	PendingDelete_AddCreatePendingRelationEntry(
								&fsObjName,
								persistentTid,
								serialNum,
								relStorageMgr,
								relationName,
								isLocalBuf,
								bufferPoolBulkLoad);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: Add '%s', relation name '%s' in state 'Create Pending', relation storage manager '%s', mirror existence state '%s', relation data resynchronization state '%s', serial number " INT64_FORMAT " at TID %s",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 relationName,
			 PersistentFileSysRelStorageMgr_Name(relStorageMgr),
			 MirroredObjectExistenceState_Name(mirrorExistenceState),
			 MirroredRelDataSynchronizationState_Name(relDataSynchronizationState),
			 *serialNum,
			 ItemPointerToString(persistentTid));
}

void PersistentRelation_AddCreated(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the create. */
	int32				segmentFileNum,
	PersistentFileSysRelStorageMgr relStorageMgr,
	PersistentFileSysRelBufpoolKind relBufpoolKind,
	MirroredObjectExistenceState mirrorExistenceState,
	MirroredRelDataSynchronizationState relDataSynchronizationState,
	int64				mirrorAppendOnlyLossEof,
	int64				mirrorAppendOnlyNewEof,
	char				*relationName,
	ItemPointer			persistentTid,
				/* Resulting TID of the gp_persistent_rel_files tuple for the relation. */
	int64				*persistentSerialNum,
				/* Resulting serial number for the relation.  Distinquishes the uses of the tuple. */
	bool 				flushToXLog)
				/* When true, the XLOG record for this change will be flushed to disk. */
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	XLogRecPtr mirrorBufpoolResyncCkptLoc;

	Datum values[Natts_gp_persistent_relation_node];

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	MemSet(&mirrorBufpoolResyncCkptLoc, 0, sizeof(XLogRecPtr));

	if (!Persistent_BeforePersistenceWork())
		elog(ERROR, "We can only add to persistent meta-data when special states");

	// Verify PersistentFileSysObj_BuildInitScan has been called.
	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	GpPersistentRelationNode_SetDatumValues(
										values,
										relFileNode->spcNode,
										relFileNode->dbNode,
										relFileNode->relNode,
										segmentFileNum,
										relStorageMgr,
										PersistentFileSysState_Created,
										/* createMirrorDataLossTrackingSessionNum */ 0,
										mirrorExistenceState,
										relDataSynchronizationState,
										/* mirrorBufpoolMarkedForScanIncrementalResync */ false,
										/* mirrorBufpoolResyncChangedPageCount */ 0,
										&mirrorBufpoolResyncCkptLoc,
										/* mirrorBufpoolResyncCkptBlockNum */ 0,
										mirrorAppendOnlyLossEof,
										mirrorAppendOnlyNewEof,
										relBufpoolKind,
										InvalidTransactionId,
										/* persistentSerialNum */ 0);	// This will be set by PersistentFileSysObj_AddTuple.

	PersistentFileSysObj_AddTuple(
							PersistentFsObjType_RelationFile,
							values,
							flushToXLog,
							persistentTid,
							persistentSerialNum);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: Add '%s', relation name '%s', in state 'Created', relation storage manager '%s', mirror existence state '%s', relation data resynchronization state '%s', serial number " INT64_FORMAT " at TID %s",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 relationName,
			 PersistentFileSysRelStorageMgr_Name(relStorageMgr),
			 MirroredObjectExistenceState_Name(mirrorExistenceState),
			 MirroredRelDataSynchronizationState_Name(relDataSynchronizationState),
			 *persistentSerialNum,
			 ItemPointerToString(persistentTid));
}

// -----------------------------------------------------------------------------
// Transaction End
// -----------------------------------------------------------------------------

/*
 * Indicate the transaction commited and the relation is officially created.
 */
void PersistentRelation_FinishBufferPoolBulkLoad(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the created relation. */
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum)
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	PersistentFileSysObjStateChangeResult stateChangeResult;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										/* segmentFileNum */ 0);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for 'Created' is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for 'Created' is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	stateChangeResult =
		PersistentFileSysObj_StateChange(
								&fsObjName,
								persistentTid,
								persistentSerialNum,
								PersistentFileSysState_CreatePending,
								/* retryPossible */ false,
								/* flushToXlog */ false,
								/* oldState */ NULL,
								/* verifiedActionCallback */ NULL);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' changed state from 'Bulk Load Create Pending' to 'Create Pending', serial number " INT64_FORMAT " at TID %s (State-Change result '%s')",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid),
			 PersistentFileSysObjStateChangeResult_Name(stateChangeResult));
}

/*
 * Indicate the transaction commited and the relation is officially created.
 */
void PersistentRelation_Created(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the created relation. */
	int32				segmentFileNum,
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum,
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
	bool				retryPossible)
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	PersistentFileSysObjStateChangeResult stateChangeResult;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for 'Created' is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for 'Created' is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	stateChangeResult =
		PersistentFileSysObj_StateChange(
								&fsObjName,
								persistentTid,
								persistentSerialNum,
								PersistentFileSysState_Created,
								retryPossible,
								/* flushToXlog */ false,
								/* oldState */ NULL,
								/* verifiedActionCallback */ NULL);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' changed state from 'Create Pending' to 'Created', serial number " INT64_FORMAT " at TID %s (State-Change result '%s')",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid),
			 PersistentFileSysObjStateChangeResult_Name(stateChangeResult));
}

/*
 * Set mirror for all relation files.
 */
void
PersistentRelation_AddMirrorAll(int16 pridbid, int16 mirdbid)
{
	Relation rel;
	HeapScanDesc scandesc;
	HeapTuple tuple;
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	if (Persistent_BeforePersistenceWork())
		elog(ERROR, "persistent table changes forbidden");

	rel = heap_open(GpPersistentRelationNodeRelationId,
				    AccessExclusiveLock);
	scandesc = heap_beginscan(rel, SnapshotNow, 0, NULL);

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	while ((tuple = heap_getnext(scandesc, ForwardScanDirection)) != NULL)
	{
		Form_gp_persistent_relation_node form =
			(Form_gp_persistent_relation_node)GETSTRUCT(tuple);
		Oid tblspcoid = form->tablespace_oid;
		Oid dboid = form->database_oid;
		Oid relfilenode_oid = form->relfilenode_oid;
		int32 segment_file_num = form->segment_file_num;
		int64 serial = form->persistent_serial_num;

		PersistentFileSysObjName fsObjName;
		RelFileNode node;

		node.spcNode = tblspcoid;
		node.dbNode = dboid;
		node.relNode = relfilenode_oid;

		PersistentFileSysObjName_SetRelationFile(&fsObjName,
												 &node,
												 segment_file_num);

	    PersistentFileSysObj_AddMirror(&fsObjName,
    	   	                           &tuple->t_self,
									   serial,
									   pridbid,
           	        	               mirdbid,
									   NULL,
									   true,
                   	        	       /* flushToXlog */ false);
	}

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;
	heap_endscan(scandesc);
	heap_close(rel, NoLock);
}

void
PersistentRelation_RemoveSegment(int16 dbid, bool ismirror)
{
	Relation rel;
	HeapScanDesc scandesc;
	HeapTuple tuple;
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	if (Persistent_BeforePersistenceWork())
		elog(ERROR, "persistent table changes forbidden");

	rel = heap_open(GpPersistentRelationNodeRelationId,
				    AccessExclusiveLock);
	scandesc = heap_beginscan(rel, SnapshotNow, 0, NULL);

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	while ((tuple = heap_getnext(scandesc, ForwardScanDirection)) != NULL)
	{
		Form_gp_persistent_relation_node form =
			(Form_gp_persistent_relation_node)GETSTRUCT(tuple);
		Oid tblspcoid = form->tablespace_oid;
		Oid dboid = form->database_oid;
		Oid relfilenode_oid = form->relfilenode_oid;
		int32 segment_file_num = form->segment_file_num;
		int64 serial = form->persistent_serial_num;

		PersistentFileSysObjName fsObjName;
		RelFileNode node;

		node.spcNode = tblspcoid;
		node.dbNode = dboid;
		node.relNode = relfilenode_oid;

		PersistentFileSysObjName_SetRelationFile(&fsObjName,
												 &node,
												 segment_file_num);

	    PersistentFileSysObj_RemoveSegment(&fsObjName,
										   &tuple->t_self,
										   serial,
										   dbid,
										   ismirror,
										   /* flushToXlog */ false);
	}

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;
	heap_endscan(scandesc);
	heap_close(rel, NoLock);
}

void
PersistentRelation_ActivateStandby(int16 oldmaster, int16 newmaster)
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	Relation rel;
	HeapScanDesc scandesc;
	HeapTuple tuple;

	if (Persistent_BeforePersistenceWork())
		elog(ERROR, "persistent table changes forbidden");

	rel = heap_open(GpPersistentRelationNodeRelationId,
				    AccessExclusiveLock);
	scandesc = heap_beginscan(rel, SnapshotNow, 0, NULL);

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	while ((tuple = heap_getnext(scandesc, ForwardScanDirection)) != NULL)
	{
		Form_gp_persistent_relation_node form =
			(Form_gp_persistent_relation_node)GETSTRUCT(tuple);
		Oid tblspcoid = form->tablespace_oid;
		Oid dboid = form->database_oid;
		Oid relfilenode_oid = form->relfilenode_oid;
		int32 segment_file_num = form->segment_file_num;
		int64 serial = form->persistent_serial_num;

		PersistentFileSysObjName fsObjName;
		RelFileNode node;

		node.spcNode = tblspcoid;
		node.dbNode = dboid;
		node.relNode = relfilenode_oid;

		PersistentFileSysObjName_SetRelationFile(&fsObjName,
												 &node,
												 segment_file_num);

	    PersistentFileSysObj_ActivateStandby(&fsObjName,
											 &tuple->t_self,
											 serial,
											 oldmaster,
											 newmaster,
											 /* flushToXlog */ false);
	}

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;
	heap_endscan(scandesc);
	heap_close(rel, NoLock);
}
/*
 * Indicate we intend to drop a relation file as part of the current transaction.
 *
 * This relation file to drop will be listed inside a commit, distributed commit, a distributed
 * prepared, and distributed commit prepared XOG records.
 *
 * For any of the commit type records, once that XLOG record is flushed then the actual
 * file-system delete will occur.  The flush guarantees the action will be retried after system
 * crash.
 */
PersistentFileSysObjStateChangeResult PersistentRelation_MarkDropPending(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the drop. */
	int32				segmentFileNum,
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum,
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
	bool				retryPossible)
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	PersistentFileSysState oldState;

	PersistentFileSysObjStateChangeResult stateChangeResult;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return false;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for mark DROP pending is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for mark DROP pending is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	stateChangeResult =
		PersistentFileSysObj_StateChange(
								&fsObjName,
								persistentTid,
								persistentSerialNum,
								PersistentFileSysState_DropPending,
								retryPossible,
								/* flushToXlog */ false,
								&oldState,
								/* verifiedActionCallback */ NULL);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' changed state from '%s' to 'Drop Pending', serial number " INT64_FORMAT " TID %s (State-Change result '%s')",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 PersistentFileSysObjState_Name(oldState),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid),
			 PersistentFileSysObjStateChangeResult_Name(stateChangeResult));

	return stateChangeResult;
}

/*
 * Indicate we are aborting the create of a relation file.
 *
 * This state will make sure the relation gets dropped after a system crash.
 */
PersistentFileSysObjStateChangeResult PersistentRelation_MarkAbortingCreate(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the aborting create. */
	int32				segmentFileNum,
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum,
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
	bool				retryPossible)
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	PersistentFileSysObjStateChangeResult stateChangeResult;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
				 "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return false;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for mark DROP pending is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for mark DROP pending is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	stateChangeResult =
		PersistentFileSysObj_StateChange(
								&fsObjName,
								persistentTid,
								persistentSerialNum,
								PersistentFileSysState_AbortingCreate,
								retryPossible,
								/* flushToXlog */ false,
								/* oldState */ NULL,
								/* verifiedActionCallback */ NULL);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' changed state from 'Create Pending' to 'Aborting Create', serial number " INT64_FORMAT " at TID %s (State-Change result '%s')",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid),
			 PersistentFileSysObjStateChangeResult_Name(stateChangeResult));

	return stateChangeResult;
}

static void
PersistentRelation_DroppedVerifiedActionCallback(
	PersistentFileSysObjName 	*fsObjName,
	ItemPointer 				persistentTid,
			/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64						persistentSerialNum,
			/* Serial number for the relation.	Distinquishes the uses of the tuple. */
	PersistentFileSysObjVerifyExpectedResult verifyExpectedResult)
{
	RelFileNode *relFileNode = PersistentFileSysObjName_GetRelFileNodePtr(fsObjName);
	int32 segmentFileNum = PersistentFileSysObjName_GetSegmentFileNum(fsObjName);

	switch (verifyExpectedResult)
	{
	case PersistentFileSysObjVerifyExpectedResult_DeleteUnnecessary:
	case PersistentFileSysObjVerifyExpectedResult_StateChangeAlreadyDone:
	case PersistentFileSysObjVerifyExpectedResult_ErrorSuppressed:
		break;

	case PersistentFileSysObjVerifyExpectedResult_StateChangeNeeded:
		/*
		 * This XLOG must be generated under the persistent write-lock.
		 */
#ifdef MASTER_MIRROR_SYNC
		mmxlog_log_remove_relfilenode(
							relFileNode->spcNode,
							relFileNode->dbNode,
							relFileNode->relNode,
							segmentFileNum);
#endif

		break;

	default:
		elog(ERROR, "Unexpected persistent object verify expected result: %d",
			 verifyExpectedResult);
	}
}

/*
 * Indicate we physically removed the relation file.
 */
void PersistentRelation_Dropped(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the dropped relation. */
	int32				segmentFileNum,
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum)
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
{
	WRITE_PERSISTENT_STATE_ORDERED_LOCK_DECLARE;

	PersistentFileSysObjName fsObjName;

	PersistentFileSysState oldState;

	PersistentFileSysObjStateChangeResult stateChangeResult;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										segmentFileNum);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for mark DROP pending is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for mark DROP pending is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	WRITE_PERSISTENT_STATE_ORDERED_LOCK;

	stateChangeResult =
		PersistentFileSysObj_StateChange(
								&fsObjName,
								persistentTid,
								persistentSerialNum,
								PersistentFileSysState_Free,
								/* retryPossible */ false,
								/* flushToXlog */ false,
								&oldState,
								PersistentRelation_DroppedVerifiedActionCallback);

	WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' changed state from '%s' to (Free), serial number " INT64_FORMAT " at TID %s (State-Change result '%s')",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 PersistentFileSysObjState_Name(oldState),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid),
			 PersistentFileSysObjStateChangeResult_Name(stateChangeResult));
}

void PersistentRelation_MarkBufPoolRelationForScanIncrementalResync(
	RelFileNode 		*relFileNode,
				/* The tablespace, database, and relation OIDs for the created relation. */
	ItemPointer			persistentTid,
				/* TID of the gp_persistent_rel_files tuple for the relation. */
	int64				persistentSerialNum)
				/* Serial number for the relation.  Distinquishes the uses of the tuple. */
{
	PersistentFileSysObjName fsObjName;

	if(RelFileNode_IsEmpty(relFileNode))
		elog(ERROR, "Invalid RelFileNode (0,0,0)");

	if (GpPersistent_SkipXLogInfo(relFileNode->relNode))
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
				 "Skipping persistent relation '%s' because it is special",
				 relpath(*relFileNode));

		return; // Resynchronize will always handle these relations as 'Scan Incremental'..
	}

	if (IsBootstrapProcessingMode())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
			     "Skipping persistent relation '%s' because we are in bootstrap mode",
				 relpath(*relFileNode));

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	if (Persistent_BeforePersistenceWork())
	{
		if (Debug_persistent_print)
			elog(Persistent_DebugPrintLevel(),
				 "Skipping persistent relation '%s' because we are before persistence work",
				 relpath(*relFileNode));

		return;	// The initdb process will load the persistent table once we out of bootstrap mode.
	}

	PersistentRelation_VerifyInitScan();

	PersistentFileSysObjName_SetRelationFile(
										&fsObjName,
										relFileNode,
										/* segmentFileNum */ 0);

	// Do this check after skipping out if in bootstrap mode.
	if (PersistentStore_IsZeroTid(persistentTid))
		elog(ERROR, "TID for persistent '%s' tuple for mark physically truncated is invalid (0,0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	if (persistentSerialNum == 0)
		elog(ERROR, "Persistent '%s' serial number for mark physcially truncated is invalid (0)",
			 PersistentFileSysObjName_TypeAndObjectName(&fsObjName));

	PersistentFileSysObj_MarkBufPoolRelationForScanIncrementalResync(
										&fsObjName,
										persistentTid,
										persistentSerialNum,
										/* flushToXlog */ true);

	if (Debug_persistent_print)
		elog(Persistent_DebugPrintLevel(),
		     "Persistent relation: '%s' marked physically truncated, serial number " INT64_FORMAT " at TID %s",
			 PersistentFileSysObjName_ObjectName(&fsObjName),
			 persistentSerialNum,
			 ItemPointerToString(persistentTid));
}

// -----------------------------------------------------------------------------
// Shmem
// -----------------------------------------------------------------------------

static Size PersistentRelation_SharedDataSize(void)
{
	return MAXALIGN(sizeof(PersistentRelationSharedData));
}

/*
 * Return the required shared-memory size for this module.
 */
Size PersistentRelation_ShmemSize(void)
{
	Size size = 0;

	/* The shared-memory structure. */
	size = add_size(size, PersistentRelation_SharedDataSize());

	return size;
}

/*
 * Initialize the shared-memory for this module.
 */
void PersistentRelation_ShmemInit(void)
{
	bool found;

	/* Create the shared-memory structure. */
	persistentRelationSharedData =
		(PersistentRelationSharedData *)
						ShmemInitStruct("Mirrored Rel File Data",
										PersistentRelation_SharedDataSize(),
										&found);

	if (!found)
	{
		PersistentFileSysObj_InitShared(
						&persistentRelationSharedData->fileSysObjSharedData);
	}

	PersistentFileSysObj_Init(
						&persistentRelationData.fileSysObjData,
						&persistentRelationSharedData->fileSysObjSharedData,
						PersistentFsObjType_RelationFile,
						/* scanTupleCallback */ NULL);

	Assert(persistentRelationSharedData != NULL);
}


text:
package uk.ac.ox.krr.logmap2.indexing;

import java.util.HashSet;
import java.util.Set;

import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnonymousIndividual;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.search.EntitySearcher;
import org.semanticweb.owlapi.search.Searcher;

import uk.ac.ox.krr.logmap2.Parameters;

/**
 *
 * This class manages the annotation that LogMap currently accepts.
 * These annotation may appear as direct strings, anonymous/named individulas or even as data assertions.
 *
 * @author Ernesto
 *
 */
public class ExtractStringFromAnnotationAssertionAxiom {

	private OWLAnonymousIndividual geneid_value;
	private OWLNamedIndividual namedIndiv;
	private IRI namedIndivIRI;

	//IRIS of alternative labels annotations
	private String rdf_label_uri = "http://www.w3.org/2000/01/rdf-schema#label";
	//private String hasRelatedSynonym_uri = "http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym";
	//private String hasExactSynonym_uri   = "http://www.geneontology.org/formats/oboInOwl#hasExactSynonym";
	//private String nci_synonym_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Synonym";
	//private String nci_umls_cui_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#UMLS_CUI";
	//private String fma_synonym_uri="http://bioontology.org/projects/ontologies/fma/fmaOwlDlComponent_2_0#Synonym";
	private String fma_name_uri="http://bioontology.org/projects/ontologies/fma/fmaOwlDlComponent_2_0#name";

	//IRIS 2 Ignore
	//private String oboinowl = "http://www.geneontology.org/formats/oboInOwl";

	//OWLDataFactory datafactory;
	//OWLOntology onto;

	public ExtractStringFromAnnotationAssertionAxiom(){

	}

	public String getAnntotationLanguage(OWLAnnotationAssertionAxiom entityAnnAx){

		String lang;

		try{
			lang = ((OWLLiteral)entityAnnAx.getAnnotation().getValue()).getLang();
		}
		catch (Exception e){
			System.err.println("Error accessing object.");
			lang="";
		}

		return lang;

	}

	public String getSingleLabel(OWLAnnotationAssertionAxiom entityAnnAx, OWLOntology onto, OWLDataFactory datafactory){

		String label_value="";

		String uri_ann = entityAnnAx.getAnnotation().getProperty().getIRI().toString();

		//Accepted URIs
		if (Parameters.accepted_annotation_URIs_for_classes.contains(uri_ann)){

			if (!(label_value=asDirectValue(entityAnnAx)).equals("")){
				return label_value;
			}
			if (!(label_value=asAnonymousIndividual(entityAnnAx, onto)).equals("")){
				return label_value;
			}
			if (!(label_value=asNamedIndividual(entityAnnAx, onto, datafactory)).equals("")){
				return label_value;
			}
			if (!(label_value=asNamedIndividualFMA(entityAnnAx, onto, datafactory)).equals("")){
				return label_value;
			}
		}

		//Empty value otherwise
		return label_value;

	}

	public Set<String> getAnntotationString(
			OWLAnnotationAssertionAxiom entityAnnAx, OWLOntology onto, OWLDataFactory datafactory){

		String label_value="";

		String uri_ann = entityAnnAx.getAnnotation().getProperty().getIRI().toString();

		//TODO Perform translation when direct annotation value

		//System.err.println(uri_ann);

		//Accepted URIs
		if (Parameters.accepted_annotation_URIs_for_classes.contains(uri_ann)){

			if (!(label_value=asDirectValue(entityAnnAx)).equals("")){
				return processLongLabels(label_value);
			}
			if (!(label_value=asAnonymousIndividual(entityAnnAx, onto)).equals("")){
				return processLongLabels(label_value);
			}
			if (!(label_value=asNamedIndividual(entityAnnAx, onto, datafactory)).equals("")){
				return processLongLabels(label_value);
			}
			if (!(label_value=asNamedIndividualFMA(entityAnnAx, onto, datafactory)).equals("")){
				return processLongLabels(label_value);
			}

		}

		return new HashSet<String>(); //empty value

	}

	private String asDirectValue(OWLAnnotationAssertionAxiom entityAnnAx){
		try	{
			//LogOutput.print(((OWLLiteral)annAx.getAnnotation().getValue()).getLiteral());

			String label = ((OWLLiteral)entityAnnAx.getAnnotation().getValue()).getLiteral().toLowerCase();

			//System.err.println(entityAnnAx + " " + label);

			if (label==null || label.equals("null") || label.equals("")){
				//System.err.println("NULL LABEL: " + entityAnnAx);
				return "";
			}

			return label;

		}
		catch (Exception e){
			//In case of error. Accessing an object in an expected way
			return "";
		}
	}

	/**
	 * As in Mouse and NCI anatomy. Annotations al rdf:labels in anonymous individuals
	 * It seems also GO ontology (to be checked)
	 * @param entityAnnAx
	 * @return
	 */
	private String asAnonymousIndividual(OWLAnnotationAssertionAxiom entityAnnAx, OWLOntology onto){
		try {
			geneid_value=((OWLAnonymousIndividual)entityAnnAx.getAnnotation().getValue()).asOWLAnonymousIndividual();//.getID()
			for (OWLAnnotationAssertionAxiom annGeneidAx : onto.getAnnotationAssertionAxioms(geneid_value)){

				if (annGeneidAx.getAnnotation().getProperty().getIRI().toString().equals(rdf_label_uri)){

					return ((OWLLiteral)annGeneidAx.getAnnotation().getValue()).getLiteral().toLowerCase();
				}
			}
			return "";
		}
		catch (Exception e){
			//In case of error. Accessing an object in an expected way
			return "";
		}
	}

	/**
	 * In some OBO like ontologies
	 * @param entityAnnAx
	 * @return
	 */
	private String asNamedIndividual(OWLAnnotationAssertionAxiom entityAnnAx, OWLOntology onto, OWLDataFactory datafactory){
		try {
			//It is an individual
			namedIndivIRI=(IRI)entityAnnAx.getAnnotation().getValue();
			namedIndiv=datafactory.getOWLNamedIndividual(namedIndivIRI);

			for (OWLAnnotationAssertionAxiom annIdiv : EntitySearcher.getAnnotationAssertionAxioms(namedIndiv, onto)){

				if (annIdiv.getAnnotation().getProperty().getIRI().toString().equals(rdf_label_uri)){

					return ((OWLLiteral)annIdiv.getAnnotation().getValue()).getLiteral().toLowerCase();
				}
			}
			return "";

		}
		catch (Exception e){
			//In case of error. Accessing an object in an expected way
			return "";
		}

	}

	/**
	 * FMA originalannotations annotations appear as datatype assertions
	 * @param entityAnnAx
	 * @return
	 */
	private String asNamedIndividualFMA(OWLAnnotationAssertionAxiom entityAnnAx, OWLOntology onto, OWLDataFactory datafactory){

		try{
			//It is an individual
			namedIndivIRI=(IRI)entityAnnAx.getAnnotation().getValue();

			namedIndiv=datafactory.getOWLNamedIndividual(namedIndivIRI);

			//for (OWLAnnotation indivAnn : namedIndiv.getAnnotations(onto)){
			for (OWLLiteral literal_syn : Searcher.values(
					onto.getDataPropertyAssertionAxioms(namedIndiv), datafactory.getOWLDataProperty(IRI.create(fma_name_uri)))){

				return literal_syn.getLiteral().toLowerCase();
			}

			return "";

		}
		catch (Exception e){
			//In case of error. Accessing an object in an expected way
			return "";
		}

	}

	/**
	 * We deal with some definitions. Long ones are discarded.
	 * We also process translated annotations
	 * @param def
	 * @return
	 */
	private Set<String> processLongLabels(String label){

		Set<String> annotation_labels = new HashSet<String>();

		String words[];

		if (label.length()<2){
			return annotation_labels;
		}

		//For translated labels: used now in ontology processing tranlateLabel method (Sept 2017)
		//Label is: trans1|trans2|...|transx
		if (label.indexOf("|")>=0){
			String[] elements = label.split("\\|");
			for (String e : elements){
				annotation_labels.add(e);
			}
			return annotation_labels;
		}

		if (label.indexOf(".")<0 || label.length()<15){ //It is not a definition
			annotation_labels.add(label);
			return annotation_labels;
		}

		//LogOutput.print("\nDEF 1: " + label);

		label = label.split("\\.")[0]; //we keep first sentence

		//LogOutput.print("\nDEF 2: " + label);

		words = label.split(" ");

		if (words.length>12){
			return annotation_labels; //empty set
		}

		//LogOutput.print("\nDEF 3: " + label);

		annotation_labels.add(label);
		return annotation_labels;

	}

}


text:
package auth

import (
	"golang.org/x/crypto/bcrypt"
)

func HashAndSalt(password string) (string, error) {
	hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	if err != nil {
		return "", nil
	}
	return string(hash), nil
}

func PasswordsMatch(hashed, plain string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hashed), []byte(plain))
	if err != nil {
		return false
	}
	return true
}


text:
extern "C" {
#if GTK_MAJOR_VERSION == 3
using GskRenderNodeType = enum {
  GSK_NOT_A_RENDER_NODE = 0,
  GSK_CONTAINER_NODE,
  GSK_CAIRO_NODE,
  GSK_COLOR_NODE,
  GSK_LINEAR_GRADIENT_NODE,
  GSK_REPEATING_LINEAR_GRADIENT_NODE,
  GSK_RADIAL_GRADIENT_NODE,
  GSK_REPEATING_RADIAL_GRADIENT_NODE,
  GSK_CONIC_GRADIENT_NODE,
  GSK_BORDER_NODE,
  GSK_TEXTURE_NODE,
  GSK_INSET_SHADOW_NODE,
  GSK_OUTSET_SHADOW_NODE,
  GSK_TRANSFORM_NODE,
  GSK_OPACITY_NODE,
  GSK_COLOR_MATRIX_NODE,
  GSK_REPEAT_NODE,
  GSK_CLIP_NODE,
  GSK_ROUNDED_CLIP_NODE,
  GSK_SHADOW_NODE,
  GSK_BLEND_NODE,
  GSK_CROSS_FADE_NODE,
  GSK_TEXT_NODE,
  GSK_BLUR_NODE,
  GSK_DEBUG_NODE,
  GSK_GL_SHADER_NODE
};

enum GdkMemoryFormat : int;

using GskRenderNode = struct _GskRenderNode;
using GtkIconPaintable = struct _GtkIconPaintable;
using GdkTexture = struct _GdkTexture;
using GdkSnapshot = struct _GdkSnapshot;
using GtkSnapshot = GdkSnapshot;
using GdkPaintable = struct _GdkPaintable;
using GtkNative = struct _GtkNative;
using GdkSurface = struct _GdkSurface;
using GdkToplevel = struct _GdkToplevel;

constexpr GdkMemoryFormat GDK_MEMORY_B8G8R8A8 = static_cast<GdkMemoryFormat>(3);

constexpr GdkModifierType GDK_ALT_MASK = GDK_MOD1_MASK;
#elif GTK_MAJOR_VERSION == 4
enum GtkWidgetHelpType : int;
enum GtkWindowType : int;

using GtkWidgetPath = struct _GtkWidgetPath;
using GtkContainer = struct _GtkContainer;
using GdkEventKey = struct _GdkEventKey;
using GdkWindow = struct _GdkWindow;
using GdkKeymap = struct _GdkKeymap;
using GtkIconInfo = struct _GtkIconInfo;
using GdkScreen = struct _GdkScreen;
using GdkColor = struct _GdkColor;

using GdkEventFunc = void (*)(GdkEvent* event, gpointer data);

struct _GdkEventKey {
  GdkEventType type;
  GdkWindow* window;
  gint8 send_event;
  guint32 time;
  guint state;
  guint keyval;
  gint length;
  gchar* string;
  guint16 hardware_keycode;
  guint8 group;
  guint is_modifier : 1;
};

struct _GdkColor {
  guint32 pixel;
  guint16 red;
  guint16 green;
  guint16 blue;
};

constexpr int GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2;
constexpr int GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3;
constexpr int GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4;

constexpr auto GTK_WINDOW_TOPLEVEL = static_cast<GtkWindowType>(0);
#else
#error "Unsupported GTK version"
#endif
}

#endif  // UI_GTK_GTK_TYPES_H_


text:
'use strict';

var assign = require('object-assign');

var errors = require('../common/errors');

var AVFSError = require('../common/avfs-error');

var MKDTEMP_LENGTH = 6;

module.exports = function (storage, constants) {
  var elements = require('../common/elements')(constants);
  var parsers  = require('../common/parsers')(constants);

  var exists = require('./exists')(storage);

  var directories = {
    mkdir: function (path, mode) {
      errors.nullCheck(path);

      if (typeof path !== 'string') {
        throw new AVFSError('path:type');
      }

      try {
        if (exists.exists(path)) {
          throw new AVFSError('EEXIST');
        }

        storage.set(path, elements.directory(parsers.mode(mode, '0777')));
      } catch (error) {
        throw assign(error, {syscall: 'mkdir', path: path});
      }
    },
    mkdtemp: function (prefix) {
      errors.nullCheck(prefix);

      var alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
      var random   = [];

      for (var i = 0; i < MKDTEMP_LENGTH; i++) {
        random.push(alphabet.charAt(Math.floor(Math.random() * alphabet.length)));
      }

      var name = (prefix.charAt(0) !== '/' ? '/' : '') + prefix + random.join('');

      try {
        directories.mkdir(name, '0700');
      } catch (error) {
        throw assign(error, {syscall: 'mkdtemp'});
      }

      return name;
    },
    readdir: function (path) {
      errors.nullCheck(path);

      if (typeof path !== 'string') {
        throw new AVFSError('path:type');
      }

      try {
        var directory = storage.get(path);

        if (directory.get('type') !== constants.S_IFDIR) {
          throw new AVFSError('ENOTDIR');
        }

        return Object.keys(directory.get('content'));
      } catch (error) {
        throw assign(error, {syscall: 'scandir', path: path});
      }
    },
    rmdir: function (path) {
      errors.nullCheck(path);

      if (typeof path !== 'string') {
        throw new AVFSError('path:type');
      }

      try {
        var directory = storage.get(path);

        if (directory.get('type') !== constants.S_IFDIR) {
          throw new AVFSError('ENOTDIR');
        }

        storage.unset(path);
      } catch (error) {
        throw assign(error, {syscall: 'rmdir', path: path});
      }
    }
  };

  return directories;
};


text:
package ru.payqr.dadataexample.rest;

import retrofit.Callback;
import retrofit.http.Body;
import retrofit.http.POST;
import ru.payqr.dadataexample.realm.models.dadata.RealmDaDataSuggestion;

/**
 * @author Savelii Zagurskii
 */
public interface DaDataService {
    @POST("/api/v2/suggest/address")
    RealmDaDataSuggestion getSuggestionSync(@Body DaDataBody body);

    @POST("/api/v2/suggest/address")
    void getSuggestionAsync(@Body DaDataBody body, Callback<RealmDaDataSuggestion> callback);
}


text:
<!DOCTYPE html>

  <title>Employee Birthday App</title>
  <base href="/">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="styles.css">
  <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">

 Employee Birthday List

    <my-app>

</my-app>
    <router-outlet></router-outlet>

copyright @ , All rights reserved to Developer


text:
      subroutine dqawfe(f,a,omega,integr,epsabs,limlst,limit,maxp1,
     *   result,abserr,neval,ier,rslst,erlst,ierlst,lst,alist,blist,
     *   rlist,elist,iord,nnlog,chebmo)
c***begin prologue  dqawfe
c***date written   800101   (yymmdd)
c***revision date  830518   (yymmdd)
c***category no.  h2a3a1
c***keywords  automatic integrator, special-purpose,
c             fourier integrals,
c             integration between zeros with dqawoe,
c             convergence acceleration with dqelg
c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
c           dedoncker,elise,appl. math. & progr. div. - k.u.leuven
c***purpose  the routine calculates an approximation result to a
c            given fourier integal
c            i = integral of f(x)*w(x) over (a,infinity)
c            where w(x)=cos(omega*x) or w(x)=sin(omega*x),
c            hopefully satisfying following claim for accuracy
c            abs(i-result).le.epsabs.
c***description
c
c        computation of fourier integrals
c        standard fortran subroutine
c        double precision version
c
c        parameters
c         on entry
c            f      - double precision
c                     function subprogram defining the integrand
c                     function f(x). the actual name for f needs to
c                     be declared e x t e r n a l in the driver program.
c
c            a      - double precision
c                     lower limit of integration
c
c            omega  - double precision
c                     parameter in the weight function
c
c            integr - integer
c                     indicates which weight function is used
c                     integr = 1      w(x) = cos(omega*x)
c                     integr = 2      w(x) = sin(omega*x)
c                     if integr.ne.1.and.integr.ne.2, the routine will
c                     end with ier = 6.
c
c            epsabs - double precision
c                     absolute accuracy requested, epsabs.gt.0
c                     if epsabs.le.0, the routine will end with ier = 6.
c
c            limlst - integer
c                     limlst gives an upper bound on the number of
c                     cycles, limlst.ge.1.
c                     if limlst.lt.3, the routine will end with ier = 6.
c
c            limit  - integer
c                     gives an upper bound on the number of subintervals
c                     allowed in the partition of each cycle, limit.ge.1
c                     each cycle, limit.ge.1.
c
c            maxp1  - integer
c                     gives an upper bound on the number of
c                     chebyshev moments which can be stored, i.e.
c                     for the intervals of lengths abs(b-a)*2**(-l),
c                     l=0,1, ..., maxp1-2, maxp1.ge.1
c
c         on return
c            result - double precision
c                     approximation to the integral x
c
c            abserr - double precision
c                     estimate of the modulus of the absolute error,
c                     which should equal or exceed abs(i-result)
c
c            neval  - integer
c                     number of integrand evaluations
c
c            ier    - ier = 0 normal and reliable termination of
c                             the routine. it is assumed that the
c                             requested accuracy has been achieved.
c                     ier.gt.0 abnormal termination of the routine. the
c                             estimates for integral and error are less
c                             reliable. it is assumed that the requested
c                             accuracy has not been achieved.
c            error messages
c                    if omega.ne.0
c                     ier = 1 maximum number of  cycles  allowed
c                             has been achieved., i.e. of subintervals
c                             (a+(k-1)c,a+kc) where
c                             c = (2*int(abs(omega))+1)*pi/abs(omega),
c                             for k = 1, 2, ..., lst.
c                             one can allow more cycles by increasing
c                             the value of limlst (and taking the
c                             according dimension adjustments into
c                             account).
c                             examine the array iwork which contains
c                             the error flags on the cycles, in order to
c                             look for eventual local integration
c                             difficulties. if the position of a local
c                             difficulty can be determined (e.g.
c                             singularity, discontinuity within the
c                             interval) one will probably gain from
c                             splitting up the interval at this point
c                             and calling appropriate integrators on
c                             the subranges.
c                         = 4 the extrapolation table constructed for
c                             convergence acceleration of the series
c                             formed by the integral contributions over
c                             the cycles, does not converge to within
c                             the requested accuracy. as in the case of
c                             ier = 1, it is advised to examine the
c                             array iwork which contains the error
c                             flags on the cycles.
c                         = 6 the input is invalid because
c                             (integr.ne.1 and integr.ne.2) or
c                              epsabs.le.0 or limlst.lt.3.
c                              result, abserr, neval, lst are set
c                              to zero.
c                         = 7 bad integrand behaviour occurs within one
c                             or more of the cycles. location and type
c                             of the difficulty involved can be
c                             determined from the vector ierlst. here
c                             lst is the number of cycles actually
c                             needed (see below).
c                             ierlst(k) = 1 the maximum number of
c                                           subdivisions (= limit) has
c                                           been achieved on the k th
c                                           cycle.
c                                       = 2 occurrence of roundoff error
c                                           is detected and prevents the
c                                           tolerance imposed on the
c                                           k th cycle, from being
c                                           achieved.
c                                       = 3 extremely bad integrand
c                                           behaviour occurs at some
c                                           points of the k th cycle.
c                                       = 4 the integration procedure
c                                           over the k th cycle does
c                                           not converge (to within the
c                                           required accuracy) due to
c                                           roundoff in the
c                                           extrapolation procedure
c                                           invoked on this cycle. it
c                                           is assumed that the result
c                                           on this interval is the
c                                           best which can be obtained.
c                                       = 5 the integral over the k th
c                                           cycle is probably divergent
c                                           or slowly convergent. it
c                                           must be noted that
c                                           divergence can occur with
c                                           any other value of
c                                           ierlst(k).
c                    if omega = 0 and integr = 1,
c                    the integral is calculated by means of dqagie
c                    and ier = ierlst(1) (with meaning as described
c                    for ierlst(k), k = 1).
c
c            rslst  - double precision
c                     vector of dimension at least limlst
c                     rslst(k) contains the integral contribution
c                     over the interval (a+(k-1)c,a+kc) where
c                     c = (2*int(abs(omega))+1)*pi/abs(omega),
c                     k = 1, 2, ..., lst.
c                     note that, if omega = 0, rslst(1) contains
c                     the value of the integral over (a,infinity).
c
c            erlst  - double precision
c                     vector of dimension at least limlst
c                     erlst(k) contains the error estimate corresponding
c                     with rslst(k).
c
c            ierlst - integer
c                     vector of dimension at least limlst
c                     ierlst(k) contains the error flag corresponding
c                     with rslst(k). for the meaning of the local error
c                     flags see description of output parameter ier.
c
c            lst    - integer
c                     number of subintervals needed for the integration
c                     if omega = 0 then lst is set to 1.
c
c            alist, blist, rlist, elist - double precision
c                     vector of dimension at least limit,
c
c            iord, nnlog - integer
c                     vector of dimension at least limit, providing
c                     space for the quantities needed in the subdivision
c                     process of each cycle
c
c            chebmo - double precision
c                     array of dimension at least (maxp1,25), providing
c                     space for the chebyshev moments needed within the
c                     cycles
c
c***references  (none)
c***routines called  d1mach,dqagie,dqawoe,dqelg
c***end prologue  dqawfe
c
      double precision a,abseps,abserr,alist,blist,chebmo,correc,cycle,
     *  c1,c2,dabs,dl,dla,dmax1,drl,d1mach,elist,erlst,ep,eps,epsa,
     *  epsabs,errsum,f,fact,omega,p,pi,p1,psum,reseps,result,res3la,
     *  rlist,rslst,uflow
      integer ier,ierlst,integr,iord,ktmin,l,last,lst,limit,limlst,ll,
     *    maxp1,momcom,nev,neval,nnlog,nres,numrl2
c
      dimension alist(limit),blist(limit),chebmo(maxp1,25),elist(limit),
     *  erlst(limlst),ierlst(limlst),iord(limit),nnlog(limit),psum(52),
     *  res3la(3),rlist(limit),rslst(limlst)
c
      external f
c
c
c            the dimension of  psum  is determined by the value of
c            limexp in subroutine dqelg (psum must be of dimension
c            (limexp+2) at least).
c
c           list of major variables
c           -----------------------
c
c           c1, c2    - end points of subinterval (of length cycle)
c           cycle     - (2*int(abs(omega))+1)*pi/abs(omega)
c           psum      - vector of dimension at least (limexp+2)
c                       (see routine dqelg)
c                       psum contains the part of the epsilon table
c                       which is still needed for further computations.
c                       each element of psum is a partial sum of the
c                       series which should sum to the value of the
c                       integral.
c           errsum    - sum of error estimates over the subintervals,
c                       calculated cumulatively
c           epsa      - absolute tolerance requested over current
c                       subinterval
c           chebmo    - array containing the modified chebyshev
c                       moments (see also routine dqc25f)
c
      data p/0.9d+00/
      data pi / 3.1415926535 8979323846 2643383279 50 d0 /
c
c           test on validity of parameters
c           ------------------------------
c
c***first executable statement  dqawfe
      result = 0.0d+00
      abserr = 0.0d+00
      neval = 0
      lst = 0
      ier = 0
      if((integr.ne.1.and.integr.ne.2).or.epsabs.le.0.0d+00.or.
     *  limlst.lt.3) ier = 6
      if(ier.eq.6) go to 999
      if(omega.ne.0.0d+00) go to 10
c
c           integration by dqagie if omega is zero
c           --------------------------------------
c
      if(integr.eq.1) call dqagie(f,0.0d+00,1,epsabs,0.0d+00,limit,
     *  result,abserr,neval,ier,alist,blist,rlist,elist,iord,last)
      rslst(1) = result
      erlst(1) = abserr
      ierlst(1) = ier
      lst = 1
      go to 999
c
c           initializations
c           ---------------
c
   10 l = dabs(omega)
      dl = 2*l+1
      cycle = dl*pi/dabs(omega)
      ier = 0
      ktmin = 0
      neval = 0
      numrl2 = 0
      nres = 0
      c1 = a
      c2 = cycle+a
      p1 = 0.1d+01-p
      uflow = d1mach(1)
      eps = epsabs
      if(epsabs.gt.uflow/p1) eps = epsabs*p1
      ep = eps
      fact = 0.1d+01
      correc = 0.0d+00
      abserr = 0.0d+00
      errsum = 0.0d+00
c
c           main do-loop
c           ------------
c
      do 50 lst = 1,limlst
c
c           integrate over current subinterval.
c
        dla = lst
        epsa = eps*fact
        call dqawoe(f,c1,c2,omega,integr,epsa,0.0d+00,limit,lst,maxp1,
     *  rslst(lst),erlst(lst),nev,ierlst(lst),last,alist,blist,rlist,
     *  elist,iord,nnlog,momcom,chebmo)
        neval = neval+nev
        fact = fact*p
        errsum = errsum+erlst(lst)
        drl = 0.5d+02*dabs(rslst(lst))
c
c           test on accuracy with partial sum
c
        if((errsum+drl).le.epsabs.and.lst.ge.6) go to 80
        correc = dmax1(correc,erlst(lst))
        if(ierlst(lst).ne.0) eps = dmax1(ep,correc*p1)
        if(ierlst(lst).ne.0) ier = 7
        if(ier.eq.7.and.(errsum+drl).le.correc*0.1d+02.and.
     *  lst.gt.5) go to 80
        numrl2 = numrl2+1
        if(lst.gt.1) go to 20
        psum(1) = rslst(1)
        go to 40
   20   psum(numrl2) = psum(ll)+rslst(lst)
        if(lst.eq.2) go to 40
c
c           test on maximum number of subintervals
c
        if(lst.eq.limlst) ier = 1
c
c           perform new extrapolation
c
        call dqelg(numrl2,psum,reseps,abseps,res3la,nres)
c
c           test whether extrapolated result is influenced by roundoff
c
        ktmin = ktmin+1
        if(ktmin.ge.15.and.abserr.le.0.1d-02*(errsum+drl)) ier = 4
        if(abseps.gt.abserr.and.lst.ne.3) go to 30
        abserr = abseps
        result = reseps
        ktmin = 0
c
c           if ier is not 0, check whether direct result (partial sum)
c           or extrapolated result yields the best integral
c           approximation
c
        if((abserr+0.1d+02*correc).le.epsabs.or.
     *  (abserr.le.epsabs.and.0.1d+02*correc.ge.epsabs)) go to 60
   30   if(ier.ne.0.and.ier.ne.7) go to 60
   40   ll = numrl2
        c1 = c2
        c2 = c2+cycle
   50 continue
c
c         set final result and error estimate
c         -----------------------------------
c
   60 abserr = abserr+0.1d+02*correc
      if(ier.eq.0) go to 999
      if(result.ne.0.0d+00.and.psum(numrl2).ne.0.0d+00) go to 70
      if(abserr.gt.errsum) go to 80
      if(psum(numrl2).eq.0.0d+00) go to 999
   70 if(abserr/dabs(result).gt.(errsum+drl)/dabs(psum(numrl2)))
     *  go to 80
      if(ier.ge.1.and.ier.ne.7) abserr = abserr+drl
      go to 999
   80 result = psum(numrl2)
      abserr = errsum+drl
  999 return
      end


text:
Reporting functionality in Taurus is delegated to special modules category. There is special [internal facility](#results-reading-and-aggregating-facility) that reads results from [executors](ExecutionSettings.md), aggregates them and feeds to configured reporters. Reporters are specified as list under top-level config key `reporting`, by default it is configured with two reporters:

```yaml
---
reporting:
    - final_stats
    - console
```

The example above uses a shorthand form for specifying reporters. Full form is using dictionaries and allows specifying some additional settings for reporters:

```yaml
---
reporting:
    - module: final_stats
    - module: console
```

Possible reporting modules are listed below.

## Post-Test Summary

This is the simplest reporter that just prints few basic KPIs in the console log after test execution, for example:

```
18:04:24 INFO: Samples count: 367, 8.17% failures
18:04:24 INFO: Average times: total 0.385, latency 0.115, connect 0.000
18:04:24 INFO: Percentile   0.0%: 0.125
18:04:24 INFO: Percentile  50.0%: 0.130
18:04:24 INFO: Percentile  90.0%: 1.168
18:04:24 INFO: Percentile  95.0%: 1.946
18:04:24 INFO: Percentile  99.0%: 2.131
18:04:24 INFO: Percentile  99.9%: 3.641
18:04:24 INFO: Percentile 100.0%: 3.641
```

This reporter is enabled by default. To enable it manually, use following config, some additional options are available:

```yaml
---
reporting:
  - module: final_stats
      summary: true  # overall samples count and percent of failures
      percentiles: true  # display average times and percentiles
      failed-labels: false  # provides list of sample labels with failures
      test-duration: true  # provides test duration
```

## Console Screen

This reporter shows fullscreen dashboard with some KPIs and even ASCII-art graphs like this:

![Console Screen](console-rsz.png)

This reporter is enabled by default. To enable it manually, use following config:

```yaml
---
reporting:
    - console
```

There is module settings for Console Screen, containing option `disable`. It allows easy disabling fullscreen display by using [command-line](CommandLine.md) switch `-o`:

```bash
bzt config.yml -o modules.console.disable=true
```

On Windows, Console Screen is shown in separate window and users may change font size by holding Ctrl key and using mouse wheel.
Two additional options are `dummy-cols` and `dummy-rows`, they affect the size of _dummy_ screen that is used for non-tty output.

## Pass/Fail Criteria

Every execution has pass/fail status and there is a way to set this status based on runtime criteria. Special `fail-criteria` reporter offers this functionality. Another useful feature of pass/fail criteria is _auto-stop_ functionality, allowing to interrupt failed tests automatically, sparing the time and resources.

Pass/fail criteria are specified as array of `criteria`, set through `reporting` item in config:

```yaml
---
reporting:
 - module: fail-criteria
   criterias:
   - avg-rt of Sample Label>150ms for 10s, stop as failed
   - fail of Sample Label>50% for 10s, stop as failed
```

The above example use short form for criteria, its general format is `subject of label{condition}threshold {logic} timeframe, action as status`, where:

  - `subject` is the KPI that will be compared, listed below
  - `label` is sample label, empty for overall
  - `{condition}` is the comparison operator, one of `>`, `<`, `>=`, `<=`, `=`, `==` (same as `=`)
  - `threshold` is the value to compare with, some KPIs allows percentage thresholds
  - `{logic}` is the way value aggregated withing timeframe, `for` means taking latest value, `within` means aggregating as average or sum (depends on criteria nature)
  - `timeframe` is number of seconds the comparison must be valid, if `timeframe` is omitted, then the cumulative value for whole test will be used for comparison.
  - `action` is one of `stop` or `continue`, default is `stop`, if you have chosen to continue, the fail status will be applied at the end of the test execution
  - `status` is one of `failed` (default) or `non-failed`

Any non-required parameters might be omitted, the minimal form is `subject{condition}threshold`.

Possible subjects are:

 - `avg-rt` - average response time, e.g. `avg-rt>2s500ms`
 - `avg-lt`- average latency, e.g. `avg-lt for mylabel>2`
 - `avg-ct` - average connect time, e.g. `avg-ct>100ms`
 - `stdev-rt` - standard deviation for full response time, e.g. `stdev-rt>0.5`
 - `p...` - percentile timing, e.g. `p90>1s for 10s`, `p99.9>10s, stop as failed`
 - `hits` - number of responses, e.g. `hits for my-label>100 for 5s, stop as non-failed`
 - `succ` or `success` - successful responses, supports percentage threshold, e.g. `succ\<100%`
 - `fail` or `failures` - failed responses, supports percentage threshold, e.g. `failures>50% for 5s, stop as failed`
 - `rc...` - response codes criteria, supports percentage threshold, response code may be specified using wildcards `?` and `\*`, e.g. `rc500>20 for 5s, stop as failed`, `rc4??>20%`, `rc\*>=10 for 1m`, `rcException>99% for 1m, continue as failed`,

The full form of the criteria is conducted by Taurus automatically from short form. You can also specify it as this:

```yaml
---
reporting:
 - module: fail-criteria
  criterias:
  - subject: avg-rt  # required
    label: 'Sample Label'  # optional, default is ''
    condition: '>'  # required
    threshold: 150ms  # required
    timeframe: 10s  # optional, default is none
    logic: for  # optional, logic to aggregate values within timeframe.
                # Default 'for' means take latest,
                # 'within' means take sum/avg of all values within interval
    fail: true  # optional, default is true
    stop: true  # optional, default is true
```

### Custom Messages for Criteria

By default, Taurus uses criteria string to present it in messages. If you want to change the message, you can do one of:
 - set `message` field for full form of criteria
 - set message by prepending it to criteria string, like this: `My message: avg-rt>10s`
 - use dictionary instead of array to specify message and criteria, like this:

```yaml
---
reporting:
 - module: fail-criteria
   criterias:
     My Message: avg-rt of Sample Label>150ms for 10s, stop as failed
     Sample Label fails too much: fail of Sample Label>50% for 10s, stop as failed
```

## BlazeMeter.com Reporting Service

Like it always happens with tools that focused on _executing_ tests, they are unable to provide sufficient reporting functionality. As professional user, you need some centralized storage to be able to access test results in convenient and interactive way, compare different executions, see trends over time and collaborate with your colleagues. [BlazeMeter.com](http://blazemeter.com) offers such service, it has both commercial and free of charge versions.

![BlazeMeter Report](blazemeter-rsz.png)

### Anonymous Usage

The simplest way to get a taste of BlazeMeter reporting is to use `-report` command-line switch. This will enable result feeding to service without any other settings required. You will receive the link for your report in the console text, and the link will be automatically opened in your default browser, see `browser-open` option for more tuning.

The official policy for BlazeMeter reports uploaded from Taurus, is that anonymous reports are kept for 7 days and if you're using your own account, then reports are kept according to the retention policy of your account. For details see BlazeMeter service [website](https://blazemeter.com/).

### Personalized Usage

If you want the results to be stored in your existing BlazeMeter account, you'll need to specify the reporting settings in your configuration file.Get the API token from BlazeMeter.com (find it under your [Settings => API Key](https://a.blazemeter.com/app/#settings/api-key)) and put it into `token` option:

```yaml
---
modules:
  blazemeter:
    token: TDknBxu0hmVnJ7NqtG2F
```

It is highly recommended to place the token setting in your personal [per-user config](CommandLine.md#configuration-files-processing) `~/.bzt-rc` to prevent it from being logged and collected in artifacts.

Now you can use `-report` command-line switch, or you can set BlazeMeter reporting as part of your config, the `test` option specifies test name to use, `project` names group of tests:

```yaml
---
reporting:
  - module: blazemeter
    test: Taurus Demo
    project: Taurus Tests Group
```

Advanced settings:

```yaml
---
modules:
  blazemeter:
    address: https://a.blazemeter.com  # reporting service address
    data-address: https://data.blazemeter.com  # data service address
    browser-open: start  # auto-open the report in browser,
                         # can be "start", "end", "both", "none"
    send-interval: 30s   # send data each n-th second
    timeout: 5  # connect and request timeout for BlazeMeter API
```

## JUnit XML Reporter

This reporter provides test results in JUnit xml format parsable by Jenkins [JUnit Plugin](https://wiki.jenkins-ci.org/display/JENKINS/JUnit+Plugin).
Reporter has two options:
- `filename` (full path to report file, optional. By default `xunit.xml` in artifacts dir)
- `data-source` (which data source to use: `sample-labels` or `pass-fail`)

If `sample-labels` used as source data, report will contain urls with test errors.
If `pass-fail` used as source data, report will contain Pass/Fail criterias information.

Sample configuration:

```yaml
---
reporting:
  - module: junit-xml
    filename: /path_to_file/file.xml
    data-source: pass-fail
```

## Results Reading and Aggregating Facility

Aggregating facility module is set through general settings, by default it is:

```yaml
---
settings:
  aggregator: consolidator
```

The `consolidator` has several settings:

```yaml
---
modules:
  consolidator:
    generalize-labels: true  # replace digits and UUID sequences
                             # with N and U to decrease label count
    ignore-labels: # sample labels from this list
                   # will be ignored by results reader
      - ignore
    buffer-seconds: 2  # this buffer is used to wait
                       # for complete data within a second
    percentiles:  # percentile levels to track,
                  # 0 also means min, 100 also means max
    - 0.0
    - 50.0
    - 90.0
    - 95.0
    - 99.0
    - 99.9
    - 100.0
```

Note that increasing `buffer-seconds` might sometimes make results aggregation more robust, by price of delaying analysis.


text:
<?xml version="1.0" encoding="utf-8"?>
<regress-exe>
  <test>
    <default>
      <files>invalidutf8.js</files>
      <baseline>invalidutf8.baseline</baseline>
      <tags>exclude_serialized</tags>
    </default>
  </test>
  <test>
    <default>
      <files>unicode_digit_as_identifier_should_work.js</files>
      <tags>exclude_serialized,bugfix,exclude_noicu</tags>
    </default>
  </test>
  <test>
    <default>
      <files>OS_2977448.js</files>
      <tags>require_winglob,BugFix</tags>
    </default>
  </test>
  <test>
    <default>
      <files>surrogatepair.js</files>
    </default>
  </test>
  <test>
    <default>
      <files>bugGH2386.js</files>
    </default>
  </test>
  <test>
    <default>
      <files>unicode_sequence_serialized.js</files>
      <compile-flags>-forceserialized -oopjit-</compile-flags>
    </default>
  </test>
  <test>
    <default>
      <files>bugGH2656.js</files>
      <compile-flags>-args summary -endargs</compile-flags>
      <tags>require_winglob,exclude_noicu</tags> <!-- Microsoft/ChakraCore#3777: Fix this test under ICU -->
    </default>
  </test>
  <test>
    <default>
      <files>utf8_console_log.js</files>
      <baseline>utf8_console_log.baseline</baseline>
      <tags>exclude_jshost</tags>
    </default>
  </test>
</regress-exe>