text:
/*
 * 2015
 */
package oli.bbp.gfx.gobj;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Comparator;
import oli.bbp.DimensionHelper;
import oli.bbp.ScriptReader;
import oli.bbp.gfx.TweenDeclaration;
import org.json.JSONArray;
import org.json.JSONObject;

/**
 *
 * @author oliver
 */
public abstract class Gobject {
    public static class GobjectZIndexComparator implements Comparator<Gobject> {
        @Override
        public int compare(Gobject o1, Gobject o2) {
            return Integer.compare(o1.zIndex, o2.zIndex);
        }
    }

    /**
     * Static array of all Gobjects.
     */
    public static ArrayList<Gobject> ago = new ArrayList<>();

    public static Gobject getGobjectById(String id) {
        for (Gobject g: ago) {
            if (g.id.equals(id)) {
                return g;
            }
        }
        return null;
    }

    public String id;
    public Rectangle bounds;
    public float opacity = 0;
    public int zIndex = 0;

    public Gobject(String id, JSONObject ja) {
        this.id = id;
        if (! ja.has("bounds")) {
            throw new ScriptReader.ScriptFormatException("Missing 'bounds' attribute for " + this.getClass().getSimpleName() + "#" + id);
        }
        JSONArray jabounds = ja.getJSONArray("bounds");
        this.bounds = new Rectangle(
            DimensionHelper.getX(jabounds.get(0)),
            DimensionHelper.getY(jabounds.get(1)),
            DimensionHelper.getX(jabounds.get(2)),
            DimensionHelper.getY(jabounds.get(3))
        );
        if (ja.has("z-index")) {
            this.zIndex = ja.getInt("z-index");
        }
        this.opacity = (float) ja.optDouble("opacity", 0.0);
    }

    // blank
    public Gobject() {

    }

    public void postConstruct() {

    }

    /**
     * Adjusts properties of the Gobject to meet tweening specifications.
     * @param td
     * @param frameNum
     */
    public void tween(TweenDeclaration td, int frameNum) {
        boolean isFirstFrame = td.startFrame == frameNum;
        boolean isLastFrame = td.endFrame == frameNum;
        int numFrame = (frameNum - td.startFrame) + 1;
        int lenFrames = td.endFrame - td.startFrame;
        if (isLastFrame) {
            this.instantChange(td, frameNum);
            return;
        }
        switch (td.affectedProperty) {
            case "bounds":
            case "relativeLocation":
                if (isFirstFrame) {
                    if (td.affectedProperty.equals("relativeLocation")) {
                        // store initial bounds
                        td.gobmem.ensureCapacity(8);
                        td.gobmem.add(this.bounds.x);
                        td.gobmem.add(this.bounds.y);
                        td.gobmem.add(this.bounds.width);
                        td.gobmem.add(this.bounds.height);

                        td.gobmem.add((double) td.json.getInt(0) / lenFrames);
                        td.gobmem.add((double) td.json.getInt(1) / lenFrames);
                        td.gobmem.add(0.0d); // no size changes with relativeLocation
                        td.gobmem.add(0.0d);
                    } else {
                        // store initial bounds
                        td.gobmem.ensureCapacity(8);
                        td.gobmem.add(this.bounds.x);
                        td.gobmem.add(this.bounds.y);
                        td.gobmem.add(this.bounds.width);
                        td.gobmem.add(this.bounds.height);

                        // also calculate & store gradients
                        td.gobmem.add(((double) td.json.getInt(0) - this.bounds.x) / lenFrames);
                        td.gobmem.add(((double) td.json.getInt(1) - this.bounds.y) / lenFrames);
                        td.gobmem.add(((double) td.json.getInt(2) - this.bounds.width) / lenFrames);
                        td.gobmem.add(((double) td.json.getInt(3) - this.bounds.height) / lenFrames);
                    }
                }
                this.bounds.setBounds(
                        (int) td.gobmem.get(0) + (int) Math.round(numFrame * (double) td.gobmem.get(4)),
                        (int) td.gobmem.get(1) + (int) Math.round(numFrame * (double) td.gobmem.get(5)),
                        (int) td.gobmem.get(2) + (int) Math.round(numFrame * (double) td.gobmem.get(6)),
                        (int) td.gobmem.get(3) + (int) Math.round(numFrame * (double) td.gobmem.get(7))
                );
            break;
            case "opacity":
                if (isFirstFrame) {
                    // store initial opacity
                    td.gobmem.add(this.opacity);
                    // store gradient
                    td.gobmem.add((double) (td.json.getDouble(0) - this.opacity) / lenFrames);
                }

                this.opacity = (float) td.gobmem.get(0) + (float) (numFrame * (double) td.gobmem.get(1));
            break;
        }
    }

    /**
     * Adjusts properties of the Gobject to meet instant change specifications.
     * @param td
     * @param frameNum
     */
    public void instantChange(TweenDeclaration td, int frameNum) {
        switch (td.affectedProperty) {
            case "bounds":
                this.bounds.setBounds(
                        td.json.getInt(0),
                        td.json.getInt(1),
                        td.json.getInt(2),
                        td.json.getInt(3)
                );
            break;
            case "opacity":
                this.opacity = (float) td.json.getDouble(0);
            break;
        }
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName() + "#" + this.id;
    }

    /**
     *
     * @param g2d
     */
    public abstract void draw(Graphics2D g2d);
}


text:
/**
 * @author: Cristian Sava
 *
 */

package zeIRC.Controller;

import java.net.Socket;
import java.util.Vector;

import zeIRC.CommunicationObjects.Group.Group;
import zeIRC.CommunicationObjects.Response.ConnectedUsersList;
import zeIRC.CommunicationObjects.User.ConnectedUser;
import zeIRC.CommunicationObjects.User.User;
//import zeIRC.CommunicationObjects.User.User;
import zeIRC.Connection.Server;

public class Control {

	private Vector<ConnectedUser> connectedUsers = null;
	private Vector<Group> groups = null;
	private Vector<User> simpleConnectedUsers = null;

	/* Singleton */
	private static Control control = null;
	protected Control () {
		connectedUsers = new Vector<ConnectedUser>();
		simpleConnectedUsers = new Vector<User>();
	}

	public static Control getInstance() {
		if (control == null) {
			control = new Control();
		}
		return control;
	}

	/**
	 *
	 * @param user
	 */

	public synchronized void addUser(ConnectedUser user) {
		connectedUsers.add(user);
		addSimpleUser(user.getUsername());
		updateConnectedUsers();
	}

	public synchronized void eliminateUser(String username) {
		for (int contor = 0; contor < connectedUsers.size(); contor++) {
			if(connectedUsers.get(contor).getUsername().equals(username)) {
				connectedUsers.remove(contor);
				break;
			}
		}
		updateConnectedUsers();
	}

	private synchronized void addSimpleUser(String username) {
		simpleConnectedUsers.add(new User(username));
	}

	public synchronized Vector<ConnectedUser> getConnectedUsers() {
		return connectedUsers;
	}

	public Boolean isOnline(String username) {
		for (ConnectedUser user : connectedUsers) {
			if(user.getUsername().equals(username)) {
				return true;
			}
		}

		return false;
	}

	private synchronized void updateConnectedUsers() {
		ConnectedUsersList usersList = new ConnectedUsersList(simpleConnectedUsers);
		String jsonObject = Serializer.convertToJson(usersList);
		for (ConnectedUser user : connectedUsers) {
			user.getOutputConnection().println(jsonObject);
		}
	}

	public synchronized void sendObjectToAllUsers(String jsonObject) {
		for (ConnectedUser user : connectedUsers) {
			user.getOutputConnection().println(jsonObject);
		}
	}

	public synchronized ConnectedUser getConnectedUser(String username) {
		for(ConnectedUser user : connectedUsers) {
			if(user.getUsername().equals(username)){
				return user;
			}
		}
		return null;
	}

	/**
	 *
	 * @param group
	 */

	public synchronized void addGroup(Group group) {
		groups.add(group);
	}

	public synchronized Vector<Group> getGroups() {
		return groups;
	}

	public static void startServer() {
		Server server = Server.getInstance(1234);
		Socket clientSocket = null;
		while(true) {
			try {
				System.out.println("Listening...");

				clientSocket = server.getClientSocket().accept();

				System.out.println("Connection...");

				Thread client = new Thread(new ClientHandler(clientSocket));
				client.start();
			} catch(Exception e) {
				e.printStackTrace();
			}
		}
	}

}

redpajama_set_name: RedPajamaGithub


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Revue mycol. , Toulouse 3(9): 20 (1881)

#### Original name
Hydnum geogenium Fr., 1852

### Remarks
null


text:
package net.sf.jabref.logic.importer.fileformat;

import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

public class SilverPlatterImporterTestNotRecognized {

    public SilverPlatterImporter testImporter;

    @Before
    public void setUp() throws Exception {
        testImporter = new SilverPlatterImporter();
    }

    @Test
    public final void testIsNotRecognizedFormat() throws Exception {
        List<String> notAccept = Arrays.asList("emptyFile.xml", "IsiImporterTest1.isi",
                "RisImporterTest1.ris", "InspecImportTest2.txt");
        for (String s : notAccept) {
            URL resource = SilverPlatterImporter.class.getResource(s);
            assertNotNull("resource " + s + " must be available", resource);
            Path file = Paths.get(resource.toURI());
            Assert.assertFalse(testImporter.isRecognizedFormat(file, StandardCharsets.UTF_8));
        }
    }

}


text:
<?php
#
# Class for table pma__designer_settings - Autobuild
# Generated on: 2016-06-16 05:08:39 pm by APIGen!
#

Class class_pma__designer_settings extends phpmyadmin {

    public function __construct($conn){

        $this->conn = $conn;

        if (!isset($_GET['do'])) {
            $this->JSN(array("error"=> "Bad url or missing parameters!"));
        } else {
            $do = strip_tags($_GET['do']);
            switch ($do) {
                case "add"    :
                    $this->add_pma__designer_settings();
                break;

                case "edit"   :
                    $this->edit_pma__designer_settings();
                break;

                case "delete" :
                    $this->delete_pma__designer_settings();
                break;

                case "list" :
                    $this->list_pma__designer_settings();
                break;

                case "search" :
                    $this->search_pma__designer_settings();
                break;
            }
        }
    }

    # Add data to table: pma__designer_settings
    public function add_pma__designer_settings() {

        if ( (isset($_POST['username'])) && (isset($_POST['settings_data'])) ) {
           # We got all fields!

            $username  = $this->escape($_POST['username'],"text");
            $settings_data  = $this->escape($_POST['settings_data'],"text");

            $qsql=("INSERT INTO `pma__designer_settings` (`username`,`settings_data`) VALUES ($username,$settings_data)") or die("Error in the consult.." . mysqli_error($this->conn));

            if ($this->conn->query($qsql)) {
                $this->JSN(array("success"=>mysqli_insert_id($this->conn)));
            } else {
                $this->JSN(array("error"=> mysqli_error($this->conn)));
            }
        } else {
           $this->JSN(array("error"=> "Bad url or missing parameters!"));
       }

    }

     # Edit data on table: pma__designer_settings
    public function edit_pma__designer_settings() {
       if () {

           # We got all fields!

            $addtoqry = "";
            if (isset($_POST['username']) && (trim($_POST['username'])!="")) {
                $username  = $this->escape($_POST['username'],"text");
                $addtoqry.="`username`=$username,";
            }
            if (isset($_POST['settings_data']) && (trim($_POST['settings_data'])!="")) {
                $settings_data  = $this->escape($_POST['settings_data'],"text");
                $addtoqry.="`settings_data`=$settings_data,";
            }

            $addtoqry = rtrim($addtoqry, ',');

            $qsql=("UPDATE `pma__designer_settings`  SET $addtoqry   ") or die("Error in the consult.." . mysqli_error($this->conn));

            if ($this->conn->query($qsql)) {
                $this->JSN(array("success"=>"Data updated!"));
            } else {
                $this->JSN(array("error"=> mysqli_error($this->conn)));
            }

       # Main value not present!
       } else {
           $this->JSN(array("error"=> "Bad url or missing parameters!"));
       }

    }

     # Delete data from table: pma__designer_settings
    public function delete_pma__designer_settings() {
       if () {

           # We got all fields!

            $qsql=("DELETE FROM `pma__designer_settings`   ") or die("Error in the consult.." . mysqli_error($this->conn));

            if ($this->conn->query($qsql)) {
                $this->JSN(array("success"=>"Data deleted!"));
            } else {
                $this->JSN(array("error"=> mysqli_error($this->conn)));
            }

       # Main value not present!
       } else {
           $this->JSN(array("error"=> "Bad url or missing parameters!"));
       }

    }

    # List data of table: pma__designer_settings
    public function list_pma__designer_settings() {
        if (isset($_GET['display'])) { $display = strip_tags($_GET['display']); } else { $display=10; }
        if (isset($_GET['page'])) { $page = strip_tags($_GET['page']); } else { $page=0; }
        if (isset($_GET['andor'])) { $andor = strip_tags($_GET['andor']); } else { $andor="AND"; }

        if ($page!=0) { $start = $page * $display;  } else { $start=0; }

        # We got all fields!

            $addtoqry = "";
            if (isset($_GET['username']) && (trim($_GET['username'])!="")) {
                $username  = $this->escape($_GET['username'],"text");
                $addtoqry.=" $andor `username`=$username,";
            }
            if (isset($_GET['settings_data']) && (trim($_GET['settings_data'])!="")) {
                $settings_data  = $this->escape($_GET['settings_data'],"text");
                $addtoqry.=" $andor `settings_data`=$settings_data,";
            }

            $addtoqry = rtrim($addtoqry, ',');

            $qsql=("SELECT * FROM `pma__designer_settings`  WHERE 1=1 $addtoqry   LIMIT $start,$display") or die("Error in the consult.." . mysqli_error($this->conn));

            if ($this->conn->query($qsql)) {
                $arr = array();
                $rez = $this->conn->query($qsql);

                # Getting total counts

                    $qsql2 = ("select * from pma__designer_settings") or die("Error in the consult.." . mysqli_error($this->conn));
                    $rez2 = $this->conn->query($qsql2);
                    $totrows = mysqli_num_rows($rez2);
                    $totpages = round($totrows/$display);
                    $arr["total_results"] = $totrows;
                    $arr["total_pages"] = $totpages;

                # end of total counts
                    if (mysqli_num_rows($rez)==0) {
                         $this->JSN(array("error"=>"No rows to display!"));
                    } else {
                        while ($r=mysqli_fetch_assoc($rez)) {
                            $arr[] = array("username"=>utf8_encode($r['username']),"settings_data"=>utf8_encode($r['settings_data']),);
                        }
                        $this->JSN($arr);
                    }

            } else {
                $this->JSN(array("error"=> mysqli_error($this->conn)));
            }

    }

    # Get data from table: pma__designer_settings
    public function get_pma__designer_settings() {

    }

    # Search data from table: pma__designer_settings
    public function search_pma__designer_settings() {

    }
}
?>


text:
<?php declare(strict_types=1);

// Grab these before we define our own classes
$internal_class_name_list = get_declared_classes();
$internal_interface_name_list = get_declared_interfaces();
$internal_trait_name_list = get_declared_traits();
$internal_function_name_list = get_defined_functions()['internal'];

use \Phan\Phan;
use \Phan\CodeBase;
use \Phan\Language\Context;
use \Phan\Language\Type;
use \Phan\Log;

define('TEST_FILE_DIR', __DIR__ . '/../files/src');
define('EXPECTED_DIR', __DIR__ . '/../files/expected');

class PhanTest extends \PHPUnit_Framework_TestCase {

    /** @var CodeBase */
    private $code_base = null;

    protected function setUp() {
        global $internal_class_name_list;
        global $internal_interface_name_list;
        global $internal_trait_name_list;
        global $internal_function_name_list;

        $this->code_base = new CodeBase(
            $internal_class_name_list,
            $internal_interface_name_list,
            $internal_trait_name_list,
            $internal_function_name_list
        );
    }

    public function tearDown() {
        $this->code_base = null;
    }

    /**
     * This reads all files in `tests/files/src`, runs
     * the analyzer on each and compares the output
     * to the files's counterpart in
     * `tests/files/expected`
     */
    public function testFiles() {

        foreach (scandir(TEST_FILE_DIR) as $test_file_name) {
            // Skip '.' and '..'
            if (empty($test_file_name)
                || '.' === $test_file_name
                || '..' === $test_file_name
            ) {
                continue;
            }

            // Get the path to the test file
            $test_file_path =
                TEST_FILE_DIR . '/' . $test_file_name;

            // Get the path of the expected output file
            $expected_file_path =
                EXPECTED_DIR . '/' . $test_file_name . '.expected';

            // Read the expected output
            $expected_output =
                trim(file_get_contents($expected_file_path));

            // Start reading everything sent to STDOUT
            // and compare it to the expected value once
            // the analzyer finishes running
            ob_start();

            try {
                // Run the analyzer
                (new Phan)->analyzeFileList(
                    clone($this->code_base),
                    [$test_file_path]
                );
            } catch (Exception $exception) {
                // TODO: inexplicably bad things happen here
                // print "\n" . $exception->getMessage() . "\n";
            }

            $output = trim(ob_get_clean());

            $wanted_re = preg_replace('/\r\n/', "\n", $expected_output);
			// do preg_quote, but miss out any %r delimited sections
            $temp = "";
            $r = "%r";
            $startOffset = 0;
            $length = strlen($wanted_re);
            while($startOffset < $length) {
                $start = strpos($wanted_re, $r, $startOffset);
                if ($start !== false) {
                    // we have found a start tag
                    $end = strpos($wanted_re, $r, $start+2);
                    if ($end === false) {
                        // unbalanced tag, ignore it.
                        $end = $start = $length;
                    }
                } else {
                    // no more %r sections
                    $start = $end = $length;
                }
                // quote a non re portion of the string
                $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)),  '/');
                // add the re unquoted.
                if ($end > $start) {
                    $temp = $temp . '(' . substr($wanted_re, $start+2, ($end - $start-2)). ')';
                }
                $startOffset = $end + 2;
            }
            $wanted_re = $temp;
            $wanted_re = str_replace(['%binary_string_optional%'], 'string', $wanted_re);
            $wanted_re = str_replace(['%unicode_string_optional%'], 'string', $wanted_re);
            $wanted_re = str_replace(['%unicode\|string%', '%string\|unicode%'], 'string', $wanted_re);
            $wanted_re = str_replace(['%u\|b%', '%b\|u%'], '', $wanted_re);
            // Stick to basics
            $wanted_re = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $wanted_re);
            $wanted_re = str_replace('%s', '[^\r\n]+', $wanted_re);
            $wanted_re = str_replace('%S', '[^\r\n]*', $wanted_re);
            $wanted_re = str_replace('%a', '.+', $wanted_re);
            $wanted_re = str_replace('%A', '.*', $wanted_re);
            $wanted_re = str_replace('%w', '\s*', $wanted_re);
            $wanted_re = str_replace('%i', '[+-]?\d+', $wanted_re);
            $wanted_re = str_replace('%d', '\d+', $wanted_re);
            $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
            $wanted_re = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re);
            $wanted_re = str_replace('%c', '.', $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression

            $this->assertRegExp("/^$wanted_re\$/", $output, "Unexpected output in $test_file_path");

/*
            $this->assertEquals(
                $expected_output,
                $output,
                "Unexpected output in $test_file_path"
            );
*/
        }
    }
}


text:
void GFXD3D9PrimitiveBuffer::prepare()
{
	static_cast<GFXD3D9Device *>( mDevice )->_setPrimitiveBuffer(this);
}

void GFXD3D9PrimitiveBuffer::unlock()
{
   #ifdef TORQUE_DEBUG

      if ( mDebugGuardBuffer )
      {
         const U32 guardSize = sizeof( _PBGuardString );

         // First check the guard areas for overwrites.
         AssertFatal( dMemcmp( mDebugGuardBuffer, _PBGuardString, guardSize ) == 0,
            "GFXD3D9PrimitiveBuffer::unlock - Caught lock memory underrun!" );
         AssertFatal( dMemcmp( mDebugGuardBuffer + mLockedSize + guardSize, _PBGuardString, guardSize ) == 0,
            "GFXD3D9PrimitiveBuffer::unlock - Caught lock memory overrun!" );

         // Copy the debug content down to the real PB.
         dMemcpy( mLockedBuffer, mDebugGuardBuffer + guardSize, mLockedSize );

         // Cleanup.
         delete [] mDebugGuardBuffer;
         mDebugGuardBuffer = NULL;
         mLockedBuffer = NULL;
         mLockedSize = 0;
      }

   #endif // TORQUE_DEBUG

   ib->Unlock();
   mLocked = false;
   mIsFirstLock = false;
   mVolatileBuffer = NULL;
}

GFXD3D9PrimitiveBuffer::~GFXD3D9PrimitiveBuffer()
{
   if( mBufferType != GFXBufferTypeVolatile )
   {
#if defined(TORQUE_OS_XENON)
      if(ib->IsSet(reinterpret_cast<GFXD3D9Device *>(mDevice)->mD3DDevice))
      {
         reinterpret_cast<GFXD3D9Device *>(mDevice)->mD3DDevice->SetIndices(NULL);
      }
#endif
      SAFE_RELEASE( ib );
   }
}

void GFXD3D9PrimitiveBuffer::zombify()
{
   if(mBufferType == GFXBufferTypeStatic)
      return;

   AssertFatal(!mLocked, "GFXD3D9PrimitiveBuffer::zombify - Cannot zombify a locked buffer!");

   if (mBufferType == GFXBufferTypeVolatile)
   {
      // We must null the volatile buffer else we're holding
      // a dead pointer which can be set on the device.
      ib = NULL;
      return;
   }

   // Dynamic buffers get released.
   SAFE_RELEASE(ib);
}

void GFXD3D9PrimitiveBuffer::resurrect()
{
   if ( mBufferType != GFXBufferTypeDynamic )
      return;

   U32 usage = D3DUSAGE_WRITEONLY;

#ifndef TORQUE_OS_XENON
   usage |= D3DUSAGE_DYNAMIC;
#endif

   D3DPOOL pool = D3DPOOL_DEFAULT;

   D3D9Assert(static_cast<GFXD3D9Device*>(mDevice)->mD3DDevice->CreateIndexBuffer( sizeof(U16) * mIndexCount ,
        usage , GFXD3D9IndexFormat[GFXIndexFormat16], pool, &ib, 0),
        "GFXD3D9PrimitiveBuffer::resurrect - Failed to allocate an index buffer.");
}


text:
package org.jeasy.batch.core.filter;

import org.jeasy.batch.core.record.Record;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class HeaderRecordFilterTest {

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private Record<String> record;

    private HeaderRecordFilter<String> headerRecordFilter;

    @Before
    public void setUp() {
        headerRecordFilter = new HeaderRecordFilter<>();
    }

    @Test
    public void whenTheRecordNumberIsEqualToOne_ThenItShouldBeFiltered() {
        when(record.getHeader().getNumber()).thenReturn(1L);
        assertThat(headerRecordFilter.processRecord(record)).isNull();
    }

    @Test
    public void whenTheRecordNumberIsDifferentFromOne_ThenItShouldNotBeFiltered() {
        when(record.getHeader().getNumber()).thenReturn(2L);
        assertThat(headerRecordFilter.processRecord(record)).isEqualTo(record);
    }

}


text:
<configuration debug="false">

  <root level="off"/>

  <appender name="TEST" class="com.kdgregory.logback.testhelpers.cloudwatch.TestableCloudWatchAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%msg</pattern>
    </layout>
    <logGroup>argle</logGroup>
    <logStream>bargle</logStream>
    <retentionPeriod>7</retentionPeriod>
    <dedicatedWriter>false</dedicatedWriter>
    <synchronous>false</synchronous> <!-- explicitly set to default value -->
    <batchDelay>9876</batchDelay>
    <truncateOversizeMessages>false</truncateOversizeMessages>
    <discardThreshold>12345</discardThreshold>
    <discardAction>newest</discardAction>
    <assumedRole>AssumableRole</assumedRole>
    <clientFactory>com.example.Foo.bar</clientFactory>
    <clientRegion>us-west-1</clientRegion>
    <clientEndpoint>logs.us-west-2.amazonaws.com</clientEndpoint>
    <useShutdownHook>false</useShutdownHook>
    <initializationTimeout>20000</initializationTimeout>
  </appender>

  <logger name="com.kdgregory.logback.aws.TestCloudWatchAppender" level="debug">
    <appender-ref ref="TEST" />
  </logger>

</configuration>


text:
The os-audit tool is the example code for
[enabling Linux auditd logs on GKE nodes](https://cloud.google.com/kubernetes-engine/docs/how-to/linux-auditd-logging),
which documents how to enable verbose operating system audit logs on Google
Kubernetes Engine nodes running Container-Optimized OS.


text:
import os
import sys

import PyFBA

import argparse

parser = argparse.ArgumentParser(description='Find roles associated with a compound')
parser.add_argument('-c', help='compound name', required=True)
args = parser.parse_args()

compounds, reactions, enzymes = PyFBA.parse.compounds_reactions_enzymes('gramnegative')

for c in compounds:
    if c.name.lower() == args.c.lower():
        wanted = c
        break

generic = wanted
generic.location = ''
if str(generic) in compounds:
    print("Roles associated with generic compound {}:".format(args.c))
    for r in PyFBA.filters.reactions_to_roles(compounds[str(generic)].reactions):
        print(r)
else:
    sys.stderr.write("No compound like {} found\n".format(generic))

intracellular = wanted
intracellular.location = 'c'
if str(intracellular) in compounds:
    print("Roles associated with the intracellular compound {}:".format(args.c))
    roles = PyFBA.filters.reactions_to_roles(compounds[str(intracellular)].reactions)
    for r in roles:
        print(r + "\t" + str(roles[r]))
else:
    sys.stderr.write("No compound like {} found\n".format(intracellular))

extracellular = wanted
extracellular.location = 'e'
if str(extracellular) in compounds:
    print("Roles associated with the extracellular compound {}:".format(args.c))
    for r in PyFBA.filters.reactions_to_roles(compounds[str(extracellular)].reactions):
        print(r)
else:
    sys.stderr.write("No compound like {} found\n".format(extracellular))


text:
var async = require('async');
var _ = require('lodash');
var path = require('path');

var access = require('any2api-access');
var util = require('any2api-util');

module.exports = util.createInvoker({
  accessModule: access,
  gatherParameters: [ { name: 'cmd' } ],
  invoke: function(ctx, callback) {
    if (!ctx.unmappedParameters.cmd) return callback(new Error('cmd parameter missing'));

    var install = function(callback) {
      var installCommand = [
        'if type apt-get > /dev/null; then sudo apt-get -y update && sudo apt-get -y install curl git; fi',
        'if type yum > /dev/null; then sudo yum -y install curl git; fi',
        //'export PYENV_ROOT="/opt/pyenv"',
        'curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash' // sudo -E bash
        //'echo \'export PYENV_ROOT="$HOME/.pyenv"\' >> ~/.bash_profile',
        //'echo \'export PATH="$PYENV_ROOT/bin:$PATH"\' >> ~/.bash_profile',
        //'echo \'eval "$(pyenv init -)"\' >> ~/.bash_profile',
        //'echo \'eval "$(pyenv virtualenv-init -)"\' >> ~/.bash_profile',
        //'source ~/.bash_profile'
      ].join(' && ');

      async.series([
        function(callback) {
          ctx.access.exec({
            command: installCommand,
            env: ctx.invokerConfig.env,
            encodingStdout: ctx.invokerConfig.encoding_stdout,
            encodingStderr: ctx.invokerConfig.encoding_stderr
          }, ctx.accessExecCallback(callback));
        }
      ], callback);
    };

    var run = function(callback) {
      var runCommand = [
        //'export PYENV_ROOT="/opt/pyenv"',
        //'export PYENV_ROOT="$HOME/.pyenv"',
        'export PATH="$PYENV_ROOT/bin:$PATH"',
        'eval "$(pyenv init -)"',
        'eval "$(pyenv virtualenv-init -)"',
        'pyenv install -s ' + ctx.invokerConfig.version,
        'pyenv rehash',
        'pyenv global ' + ctx.invokerConfig.version
      ];

      if (ctx.invokerConfig.virtualenv) {
        runCommand.push('pyenv virtualenv -f ' + ctx.invokerConfig.version + ' ' + ctx.invokerConfig.virtualenv);
        runCommand.push('pyenv activate ' + ctx.invokerConfig.virtualenv);
      }

      if (!ctx.invokerConfig.skip_requirements) {
        runCommand.push('pip install -r $INSTANCE_PATH/requirements.txt');
        runCommand.push('pyenv rehash');
      }

      runCommand.push('echo "' + ctx.invokerConfig.stdin + '" | ' + ctx.unmappedParameters.cmd);
      runCommand = runCommand.join(' && ');

      async.series([
        //async.apply(ctx.access.remove, { path: ctx.instancePath }),
        async.apply(ctx.access.mkdir, { path: ctx.instancePath }),
        async.apply(ctx.access.mkdir, { path: ctx.invokerConfig.cwd }),
        function(callback) {
          if (!ctx.executablePath) return callback();

          ctx.access.copyDirToRemote({ sourcePath: ctx.executablePath, targetPath: ctx.instancePath }, callback);
        },
        function(callback) {
          ctx.access.exists({ path: path.join(ctx.instancePath, 'requirements.txt') }, function(err, exists) {
            if (err || exists) return callback(err);

            ctx.access.writeFile({ path: path.join(ctx.instancePath, 'requirements.txt'), content: ctx.invokerConfig.requirements || '' }, callback);
          });
        },
        function(callback) {
          ctx.access.exec({
            command: runCommand,
            env: ctx.invokerConfig.env,
            //stdin: ctx.invokerConfig.stdin || '',
            cwd: ctx.invokerConfig.cwd,
            encodingStdout: ctx.invokerConfig.encoding_stdout,
            encodingStderr: ctx.invokerConfig.encoding_stderr
          }, ctx.accessExecCallback(callback));
        }
      ], callback);
    };

    ctx.invokerConfig.env.PYENV_ROOT = ctx.invokerConfig.env.PYENV_ROOT || '/opt/pyenv';
    ctx.invokerConfig.version = ctx.invokerConfig.version || '2.7.8';

    try {
      if (!_.isEmpty(ctx.invokerConfig.args)) {
        ctx.unmappedParameters.cmd = _.template(ctx.unmappedParameters.cmd)(ctx.invokerConfig.args);
      }
    } catch (err) {
      return callback(new Error('error while building command using args: ' + err.message));
    }

    async.series([
      function(callback) {
        ctx.access.exists({ path: ctx.invokerConfig.env.PYENV_ROOT }, function(err, exists) {
          if (err) callback(err);
          else if (!exists) install(callback);
          else callback();
        });
      },
      async.apply(run)
    ], callback);
  }
});


text:
package org.apache.reef.runtime.common.launch;

import org.apache.reef.runtime.common.launch.parameters.LaunchID;
import org.apache.reef.tang.annotations.Parameter;
import org.apache.reef.wake.EventHandler;
import org.apache.reef.wake.profiler.WakeProfiler;
import org.apache.reef.wake.time.event.StopTime;

import javax.inject.Inject;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * An EventHandler that writes out the profiler results.
 */
public final class ProfilingStopHandler implements EventHandler<StopTime> {
  private static final Logger LOG = Logger.getLogger(ProfilingStopHandler.class.getName());
  private static WakeProfiler profiler;
  private final String launchID;

  @Inject
  public ProfilingStopHandler(@Parameter(LaunchID.class) final String launchID) {
    this.launchID = launchID;
  }

  public static void setProfiler(final WakeProfiler profiler) {
    ProfilingStopHandler.profiler = profiler;
  }

  @Override
  public void onNext(final StopTime stopTime) {
    try (final PrintWriter out = new PrintWriter("profile-" + launchID + ".json", "UTF-8")) {
      out.print(profiler.objectGraphToString());
    } catch (final FileNotFoundException | UnsupportedEncodingException e) {
      LOG.log(Level.WARNING, "Unable to write the profile", e);
    }
  }
}


text:
<?php

namespace Glad\Grants;

use Glad\Interfaces\DatabaseServiceInterface;

class DatabaseService implements DatabaseServiceInterface
{
	public function get($driver)
	{
		return new $driver;
	}
}


text:
#ifndef HTTP_H_
#define HTTP_H_

/* All HTTP constants, status codes, version numbers, etc. go here */

#define HTTP_VERSION_NUM "1.1"

#define HTTP_200_NAME "OK"
#define HTTP_400_NAME "Bad Request"
#define HTTP_404_NAME "Not Found"
#define HTTP_500_NAME "Internal Server Error"
#define HTTP_501_NAME "Not Implemented"

enum HTTP_Method
{
    OPTIONS = 1,
    GET = 2,
    HEAD = 3,
    POST = 4,
    PUT = 5,
    DELETE = 6,
    TRACE = 7,
    CONNECT = 8
};

typedef struct
{
    /* first line of request */
    enum HTTP_Method method;
    char* uri;
    int major_version;
    int minor_version;
} HTTP_Request_Header;

#endif /* HTTP_H_ */


text:
#ifndef _XENVBD_TYPES_H
#define _XENVBD_TYPES_H

typedef enum _DEVICE_PNP_STATE {
    Invalid = 0,
    Present,        // PDO only
    Enumerated,     // PDO only
    Added,          // FDO only
    Started,
    StopPending,
    Stopped,
    RemovePending,
    SurpriseRemovePending,
    Deleted
} DEVICE_PNP_STATE, *PDEVICE_PNP_STATE;

typedef enum _XENVBD_DEVICE_TYPE {
    XENVBD_DEVICE_TYPE_DISK,
    XENVBD_DEVICE_TYPE_CDROM,
    XENVBD_DEVICE_TYPE_UNKNOWN
} XENVBD_DEVICE_TYPE, *PXENVBD_DEVICE_TYPE;

#endif // _XENVBD_TYPES_H


text:
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace TitaniumAS.Opc.Client.Interop.Common
{
    [InterfaceType(1)]
    [Guid("55C382C8-21C7-4E88-96C1-BECFB1E3F483")]
    [ComImport]
    interface IOPCEnumGUID
    {
        [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        void Next([In] int celt,
            [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct), Out] Guid[] rgelt,
            out int pceltFetched);

        [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        void Skip([In] int celt);

        [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        void Reset();

        [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        void Clone([MarshalAs(UnmanagedType.Interface)] out IOPCEnumGUID ppenum);
    }
}


text:
package paddlecloud

import (
	"context"
	"encoding/json"
	"errors"
	"flag"
	"fmt"
	"os"
	"path"
	"strings"

	"github.com/PaddlePaddle/cloud/go/utils/config"
	"github.com/PaddlePaddle/cloud/go/utils/restclient"
	"github.com/golang/glog"
	"github.com/google/subcommands"
)

const (
	invalidJobName = "jobname can not contain '.' or '_'"
)

// Config is global config object for paddlecloud commandline
var Config = config.ParseDefaultConfig()

// SubmitCmd define the subcommand of submitting paddle training jobs.
type SubmitCmd struct {
	Jobname     string `json:"name"`
	Jobpackage  string `json:"jobPackage"`
	Parallelism int    `json:"parallelism"`
	CPU         int    `json:"cpu"`
	GPU         int    `json:"gpu"`
	Memory      string `json:"memory"`
	Pservers    int    `json:"pservers"`
	PSCPU       int    `json:"pscpu"`
	PSMemory    string `json:"psmemory"`
	Entry       string `json:"entry"`
	Topology    string `json:"topology"`
	Datacenter  string `json:"datacenter"`
	Passes      int    `json:"passes"`
	// docker image to run jobs
	Image    string `json:"image"`
	Registry string `json:"registry"`
	// Alpha features:
	// TODO: separate API versions
	FaultTolerant bool `json:"faulttolerant"`
}

// Name is subcommands name.
func (*SubmitCmd) Name() string { return "submit" }

// Synopsis is subcommands synopsis.
func (*SubmitCmd) Synopsis() string { return "Submit job to PaddlePaddle Cloud." }

// Usage is subcommands Usage.
func (*SubmitCmd) Usage() string {
	return `submit [options] <package path>:
	Submit job to PaddlePaddle Cloud.
	Options:
`
}

// SetFlags registers subcommands flags.
func (p *SubmitCmd) SetFlags(f *flag.FlagSet) {
	f.StringVar(&p.Jobname, "jobname", "paddle-cluster-job", "Cluster job name.")
	f.IntVar(&p.Parallelism, "parallelism", 1, "Number of parrallel trainers. Defaults to 1.")
	f.IntVar(&p.CPU, "cpu", 1, "CPU resource each trainer will use. Defaults to 1.")
	f.IntVar(&p.GPU, "gpu", 0, "GPU resource each trainer will use. Defaults to 0.")
	f.StringVar(&p.Memory, "memory", "1Gi", " Memory resource each trainer will use. Defaults to 1Gi.")
	f.IntVar(&p.Pservers, "pservers", 0, "Number of parameter servers. Defaults equal to -p")
	f.IntVar(&p.PSCPU, "pscpu", 1, "Parameter server CPU resource. Defaults to 1.")
	f.StringVar(&p.PSMemory, "psmemory", "1Gi", "Parameter server momory resource. Defaults to 1Gi.")
	f.StringVar(&p.Entry, "entry", "", "Command of starting trainer process. Defaults to paddle train")
	f.StringVar(&p.Topology, "topology", "", "Will Be Deprecated .py file contains paddle v1 job configs")
	f.IntVar(&p.Passes, "passes", 1, "Pass count for training job")
	f.StringVar(&p.Image, "image", "", "Runtime Docker image for the job")
	f.StringVar(&p.Registry, "registry", "", "Registry secret name for the runtime Docker image")
	f.BoolVar(&p.FaultTolerant, "faulttolerant", false, "if true, use new fault-tolerant pservers")
}

// Execute submit command.
func (p *SubmitCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
	if f.NArg() != 1 {
		f.Usage()
		return subcommands.ExitFailure
	}
	// default pservers count equals to trainers count.
	if p.Pservers == 0 {
		p.Pservers = p.Parallelism
	}
	p.Jobpackage = f.Arg(0)
	p.Datacenter = Config.ActiveConfig.Name

	s := NewSubmitter(p)
	errS := s.Submit(f.Arg(0), p.Jobname)
	if errS != nil {
		fmt.Fprintf(os.Stderr, "error submiting job: %v\n", errS)
		return subcommands.ExitFailure
	}
	fmt.Printf("%s submited.\n", p.Jobname)
	return subcommands.ExitSuccess
}

// Submitter submit job to cloud.
type Submitter struct {
	args *SubmitCmd
}

// NewSubmitter returns a submitter object.
func NewSubmitter(cmd *SubmitCmd) *Submitter {
	s := Submitter{cmd}
	return &s
}

// Submit current job.
func (s *Submitter) Submit(jobPackage string, jobName string) error {
	if err := checkJobName(jobName); err != nil {
		return err
	}
	// if jobPackage is not a local dir, skip uploading package.
	_, pkgerr := os.Stat(jobPackage)
	if pkgerr == nil {
		dest := path.Join("/pfs", Config.ActiveConfig.Name, "home", Config.ActiveConfig.Username, "jobs", jobName)
		if !strings.HasSuffix(jobPackage, "/") {
			jobPackage = jobPackage + "/"
		}
		err := putFiles(jobPackage, dest)
		if err != nil {
			return err
		}
	} else if os.IsNotExist(pkgerr) {
		glog.Warning("jobpackage not a local dir, skip upload.")
	}
	// 2. call paddlecloud server to create kubernetes job
	jsonString, err := json.Marshal(s.args)
	if err != nil {
		return err
	}
	glog.V(10).Infof("Submitting job: %s to %s\n", jsonString, Config.ActiveConfig.Endpoint+"/api/v1/jobs")
	respBody, err := restclient.PostCall(Config.ActiveConfig.Endpoint+"/api/v1/jobs/", jsonString)
	if err != nil {
		return err
	}
	var respObj interface{}
	if err = json.Unmarshal(respBody, &respObj); err != nil {
		return err
	}
	// FIXME: Return an error if error message is not empty. Use response code instead
	errMsg := respObj.(map[string]interface{})["msg"].(string)
	if len(errMsg) > 0 {
		return errors.New(errMsg)
	}
	return nil
}
func checkJobName(jobName string) error {
	if strings.Contains(jobName, "_") || strings.Contains(jobName, ".") {
		return errors.New(invalidJobName)
	}
	return nil
}


text:
/* Kyle Bowerman 12/10/2013
   Purpose:
   To create random Leads of synthetic data and insert them into Salesforce via Nforce
   It uses Faker.js [https://github.com/marak/Faker.js/] to generate synthetic
   Leads with good spread but can easily by modified to create any object.

   Instructions:
   1. Set 4 environmental vars:  SFUSER, SFPASS, CLIENTID, CLIENTSECRET in an .env file, export global var, or hard-code values in this file
   2. Modify the value for newLeadCount in the generateData function to determine how many random leads to create.
   3. This script will generate a output json file called leadOut.json prior to inserting the leads.   If you like you can comment out the insertLead
      call in order to just generate the json output to insert via data loader.   To do this you should get jq to convert this json file to csv.
      The command would be something like this:
      cat leadOut.json | jq -r '.[] | [.firstName,.phone, .company.name] | @csv'

   Modifications to ../lib/Faker.js
   1. Faker.Helpers.sfLead was created, you should edit this or create a new helper for each object you which to insert.
   2. I created Faker.Internet.kyleEmail since the original would use a new firstname and lastname to create an email instead
   of the firstname and lastname inserted into the lead.
   3. Same thing for Faker.Internet.kyleUserName
   4. Faker.definition.tv_channel  and Faker.definitions.ticker which contain Comcast TV Chanel listings and NYSE ticker respectively to demonstrate
      how to create custom data types.  Of course these are not inserted into the lead because it would be a custom field.   But I think you get the picture.
 */
var sys = require('sys');
var fs = require('fs');
var nforce = require('../');
var Faker = require('../lib/Faker');

var sfuser = process.env.SFUSER;
var sfpass = process.env.SFPASS;
var clientId = process.env.CLIENTID;
var clientSecret = process.env.CLIENTSECRET;

var oauth = '';

var org = nforce.createConnection({
    clientId: clientId,
    clientSecret: clientSecret,
    redirectUri: 'http://localhost:3000/oauth/_callback',
    apiVersion: 'v27.0', // optional, defaults to current salesforce API version
    environment: 'production', // optional, salesforce 'sandbox' or 'production', production default
    mode: 'multi' // optional, 'single' or 'multi' user mode, multi default
});

function insertLead(data) {
    console.log('Attempting to insert lead ' + data.firstName + ' ' + data.lastName);
    var ld = nforce.createSObject('Lead', {
        FirstName: data.firstName,
        LastName: data.lastName,
        Company: data.company.name,
        State: data.address.state,
        City: data.address.city,
        Street: data.address.street,
        PostalCode: data.address.zipcode,
        Phone: data.phone,
        MobilePhone: data.mobilePhone,
        Email: data.email,
        Website: data.website,
        Latitude: data.address.geo.lat,
        Longitude: data.address.geo.lng,
        //batch__c: '003' // kyle uses this
    });
    org.insert(ld, oauth, function (err, resp) {
        if (err) {
            console.error('--> unable to insert lead');
            console.error('--> ' + JSON.stringify(err));
        } else {
            console.log(data.firstName + ' ' + data.lastName + '--> lead inserted');
        }
    });
}

// generate Synthetic data using ../lib/Faker.js  Faker.Helpers.sfLead method.  You can reuse this or create your own.
function generateData() {
    var bigSet = [];
    var newLeadCount = 20;

    for (var i = 0; i < newLeadCount; i++) {
        bigSet.push(Faker.Helpers.sfLead());
        console.log('created', bigSet[i].lastName);
        insertLead(bigSet[i]);
    }

    fs.writeFile('leadOut.json', JSON.stringify(bigSet), function () {
        sys.puts("json data generated successfully to leadOut.json !");
    });
}

console.log('Authenticating with Salesforce');

org.authenticate({
    username: sfuser,
    password: sfpass
}, function (err, resp) {
    if (err) {
        console.error('--> unable to authenticate to sfdc');
        console.error('--> ' + JSON.stringify(err));
    } else {
        console.log('--> authenticated!');
        oauth = resp;
        generateData();
    }
});


text:
package pr03.animal;

import pr03.food.Food;

public class Zebra extends Mammal {

    public Zebra(String animalName, double animalWeight, String livingRegion) {
        super(animalName, animalWeight, livingRegion);
    }

    @Override
    public void makeSound() {
        System.out.println("Zs");
    }

    @Override
    public void eatFood(Food food) {

        if (((Food)food).getClass().getSimpleName().equals("Meat")) {
            throw new IllegalArgumentException("Zebras are not eating that type of food!");
        }

        int currFood = this.getFoodEaten();
        if (food.getQuantity() > 0) {
            this.setFoodEaten(currFood + food.getQuantity());
        }
    }
}


text:
import java.io.*;
import java.util.*;

class SuperWashingMachines
{
    public static void main(String[] args)
    {
	System.out.println("=== Super Washing Machines ===");
	Solution solution = new Solution();
        int[][] machines_array = {{1,0,5},
                                  {0,3,0},
                                  {0,2,0}};
        for(int i = 0; i < machines_array.length; i++) {
            int[] machines = machines_array[i];

            System.out.println("machines = "+Arrays.toString(machines)+", min moves = "+solution.findMinMoves(machines));
        }
    }
}

class Solution
{
    public int findMinMoves(int[] machines) {
        int ret = 0;
        int sum = 0;
        int avg = 0;

        if(machines == null || machines.length <= 1) { return 0; }
        int size = machines.length;

        for(int i = 0; i < size; i++) { sum += machines[i]; }
        if(sum%size != 0) { return -1; }
        avg = sum/size;

        int[] shifts = new int[size];
        int count = 0;
        for(int i = 0; i < size; i++) {
            shifts[i] = count - avg*i;
            count += machines[i];
        }

        System.out.println("shifts = "+Arrays.toString(shifts));

        return ret;
    }
}


text:
- **[Known Issues](#known-issues)**
- **[Breaking Changes](#breaking-changes)**
  - [Flags](#flags)
  - [VTTablet Flag Deletions](#vttablet-flag-deletions)
  - [Vindex Interface](#vindex-interface)
- **[Deprecations](#deprecations)**
  - [LogStats Table and Keyspace Deprecated](#logstats-table-and-keyspace-deprecated)
  - [Orchestrator Integration Deprecation](#orchestrator-integration-deprecation)
  - [Connection Pool Prefill](#connection-pool-prefill)
  - [InitShardPrimary Deprecation](#initshardprimary-deprecation)
- **[Command-Line Syntax Deprecations](#command-line-syntax-deprecations)**
  - [VTTablet Startup Flag Deletions](#vttablet-startup-flag-deletions)
  - [VTTablet Startup Flag Deprecations](#vttablet-startup-flag-deprecations)
  - [VTBackup Flag Deprecations](#vtbackup-flag-deprecations)
- **[VTGate](#vtgate)**
  - [vtgate --mysql-server-pool-conn-read-buffers](#vtgate--mysql-server-pool-conn-read-buffers)
- **[VDiff2](#vdiff2)**
  - [Resume Workflow](#resume-workflow)
- **[New command line flags and behavior](#new-command-line)**
  - [vtctl GetSchema --table-schema-only](#vtctl-getschema--table-schema-only)
  - [Support for Additional Compressors and Decompressors During Backup & Restore](#support-for-additional-compressors-and-decompressors-during-backup-&-restore)
  - [Independent OLAP and OLTP Transactional Timeouts](#independant-olap-and-oltp-transactional-timeouts)
  - [Support for Specifying Group Information in Calls to VTGate](#support-for-specifying-group-information-in-calls-to-vtgate)
- **[Online DDL Changes](#online-ddl-changes)**
  - [Concurrent Vitess Migrations](#concurrent-vitess-migrations)
  - [VTCtl Command Changes](#vtctl-command-changes)
  - [New Syntax](#new-syntax)
- **[Tablet Throttler](#tablet-throttler)**
  - [API Changes](#api-changes)
- **[Mysql Compatibility](#mysql-compatibility)**
  - [System Settings](#system-settings)
  - [Lookup Vindexes](#lookup-vindexes)
- **[Durability Policy](#durability-policy)**
  - [Cross Cell](#cross-cell)
- **[New EXPLAIN Format](#new-explain-format)**
  - [FORMAT=vtexplain](#formatvtexplain)
- **[VTOrc](#vtorc)**
  - [Old UI Removal and Replacement](#old-ui-removal-and-replacement)
  - [Configuration Refactor and New Flags](#configuratoin-refactor-and-new-flags)
  - [Example Upgrade](#example-upgrade)
  - [Default Configuration Files](#default-configuration-files)
- **[Flags Restructure](#flags-restructure)**
  - [Flags Diff](#flags-diff)

## Known Issues

- [Corrupted results for non-full-group-by queries with JOINs](https://github.com/vitessio/vitess/issues/11625). This can be resolved by using full-group-by queries.

## Major Changes

### Breaking Changes

#### Flags

- The deprecated `--cpu_profile` flag has been removed. Please use the `--pprof` flag instead.
- The deprecated `--mem-profile-rate` flag has been removed. Please use `--pprof=mem` instead.
- The deprecated `--mutex-profile-fraction` flag has been removed. Please use `--pprof=mutex` instead.
- The deprecated vtgate/vtexplain/vtcombo flag `--planner_version` has been removed. Please use `--planner-version` instead.
- The deprecated flag `--master_connect_retry` has been removed. Please use `--replication_connect_retry` instead.
- `vtctl` commands that take shard names and ranges as positional arguments (e.g. `vtctl Reshard ks.workflow -80 -40,40-80`) need to have their positional arguments separated from their flag arguments by a double-dash separator to avoid the new parsing library from mistaking them as flags (e.g. `vtctl Reshard ks.workflow -- -80 -40,40-80`).
- The `--cell` flag in the `vtgate` binary no longer has a default value. It is a required argument that has to be specified for the binary to run. Please explicitly specify the flag, if dependent on the flag's default value.
- The `--db-config-*-*` VTTablet flags were deprecated in `v3.0.0`. They have now been deleted as part of this release. You must use `--db_dba_*` now.

#### vttablet Flag Deletions
The following VTTablet flags were deprecated in 7.0. They have now been deleted
- `--queryserver-config-message-conn-pool-size`
- `--queryserver-config-message-conn-pool-prefill-parallelism`
- `--client-found-rows-pool-size` A different existing flag `--queryserver-config-transaction-cap` will be used instead
- `--transaction_shutdown_grace_period` Use `--shutdown_grace_period` instead
- `--queryserver-config-max-dml-rows`
- `--queryserver-config-allowunsafe-dmls`
- `--pool-name-prefix`
- `--enable-autocommit` Autocommit is always allowed

#### Vindex Interface

All the vindex interface methods are changed by adding `context.Context` as an input parameter.

E.g:
```go
Map(vcursor VCursor, .... ) ....
	To
Map(ctx context.Context, vcursor VCursor, .... ) ....
```

This only affects users who have added their own custom vindex implementation.
They are required to change their implementation with these new interface method expectations.

### Deprecations

#### LogStats Table and Keyspace deprecated

Information about which tables are used was being reported through the `Keyspace` and `Table` fields on LogStats.
For multi-table queries, this output can be confusing, so we have added `TablesUsed`, that is a string array, listing all tables and which keyspace they are on.
`Keyspace` and `Table` fields are deprecated and will be removed in the v16 release of Vitess.

#### Orchestrator Integration Deprecation

Orchestrator integration in `vttablet` has been deprecated. It will continue to work in this release but is liable to be removed in future releases.
Consider using VTOrc instead of Orchestrator as VTOrc goes GA in this release.

#### Connection Pool Prefill

The connection pool with prefilled connections have been removed. The pool now does lazy connection creation.

#### InitShardPrimary Deprecation

The vtcltd command InitShardPrimary has been deprecated. Please use PlannedReparentShard instead.

### Command-line syntax deprecations

#### vttablet startup flag deletions
The following VTTablet flags were deprecated in 7.0. They have now been deleted
- --queryserver-config-message-conn-pool-size
- --queryserver-config-message-conn-pool-prefill-parallelism
- --client-found-rows-pool-size --queryserver-config-transaction-cap will be used instead
- --transaction_shutdown_grace_period Use --shutdown_grace_period instead
- --queryserver-config-max-dml-rows
- --queryserver-config-allowunsafe-dmls
- --pool-name-prefix
- --enable-autocommit Autocommit is always allowed

#### vttablet startup flag deprecations
- `--enable-query-plan-field-caching` has been deprecated. It will be removed in v16.
- `--enable_semi_sync` has been deprecated. It will be removed in v16. Instead, set the correct durability policy using `SetKeyspaceDurabilityPolicy`
- `--queryserver-config-pool-prefill-parallelism`, `--queryserver-config-stream-pool-prefill-parallelism` and `--queryserver-config-transaction-prefill-parallelism` have all been deprecated. They will be removed in v16.
- `--backup_storage_hook` has been deprecated, consider using one of the builtin compression algorithms or `--external-compressor` and `--external-decompressor` instead.

#### vtbackup flag deprecations
- `--backup_storage_hook` has been deprecated, consider using one of the builtin compression algorithms or `--external-compressor` and `--external-decompressor` instead.

### VTGate

#### vtgate --mysql-server-pool-conn-read-buffers

`--mysql-server-pool-conn-read-buffers` enables pooling of buffers used to read from incoming
connections, similar to the way pooling happens for write buffers. Defaults to off.

### VDiff v2

#### Resume Workflow

We introduced the ability to resume a VDiff2 workflow:
```
$ vtctlclient --server=localhost:15999 VDiff --v2 customer.commerce2customer resume 4c664dc2-eba9-11ec-9ef7-920702940ee0
VDiff 4c664dc2-eba9-11ec-9ef7-920702940ee0 resumed on target shards, use show to view progress

$ vtctlclient --server=localhost:15999 VDiff --v2 customer.commerce2customer show last

VDiff Summary for customer.commerce2customer (4c664dc2-eba9-11ec-9ef7-920702940ee0)
State:        completed
RowsCompared: 196
HasMismatch:  false
StartedAt:    2022-06-26 22:44:29
CompletedAt:  2022-06-26 22:44:31

Use "--format=json" for more detailed output.

$ vtctlclient --server=localhost:15999 VDiff --v2 --format=json customer.commerce2customer show last
{
	"Workflow": "commerce2customer",
	"Keyspace": "customer",
	"State": "completed",
	"UUID": "4c664dc2-eba9-11ec-9ef7-920702940ee0",
	"RowsCompared": 196,
	"HasMismatch": false,
	"Shards": "0",
	"StartedAt": "2022-06-26 22:44:29",
	"CompletedAt": "2022-06-26 22:44:31"
}
```

We leverage this resume capability to automatically restart a VDiff2 workflow that encountered a retryable error.

We also made a number of other enhancements like progress reporting and features needed to make it a full replacement for VDiff v1. You can see more details in the tracking ticket for the VDiff2 feature complete target: https://github.com/vitessio/vitess/issues/10494

Now that VDiff v2 is feature complete in 15.0, we hope to make it GA in 16.0.

Please see the VDiff2 [documentation](https://vitess.io/docs/15.0/reference/vreplication/vdiff2/) for additional information.

### New command line flags and behavior

#### vtctl GetSchema --table-schema-only

The new flag `--table-schema-only` skips column introspection. `GetSchema` only returns general schema analysis, and specifically it includes the `CREATE TABLE|VIEW` statement in the `schema` field.

#### Support for additional compressors and decompressors during backup & restore
Backup/Restore now allow you many more options for compression and decompression instead of relying on the default compressor(`pargzip`).
There are some built-in compressors which you can use out-of-the-box. Users will need to evaluate which option works best for their
use-case. Here are the flags that control this feature

- `--compression-engine-name`
- `--external-compressor`
- `--external-decompressor`
- `--external-compressor-extension`
- `--compression-level`

`--compression-engine-name` specifies the engine used for compression. It can have one of the following values

- pargzip (Default)
- pgzip
- lz4
- zstd
- external

If you want to use any of the built-in compressors, simply set one of the above values other than `external` for `--compression-engine-name`. The value
specified in `--compression-engine-name` is saved in the backup MANIFEST, which is later read by the restore process to decide which
engine to use for decompression. Default value for engine is 'pargzip'.

If you would like to use a custom command or external tool for compression/decompression then you need to provide the full command with
arguments to the `--external-compressor` and `--external-decompressor` flags. `--external-compressor-extension` flag also needs to be provided
so that compressed files are created with the correct extension. If the external command is not using any of the built-in compression engines
(i.e. pgzip, pargzip, lz4 or zstd) then you need to set `--compression-engine-name` to value 'external'.

Please note that if you want to keep the current behavior then you don't need to provide any of these flags.
You can read more about backup & restore [here] (https://vitess.io/docs/15.0/user-guides/operating-vitess/backup-and-restore/).

If you decided to switch from an external compressor to one of the built-in supported compressors (i.e. pgzip, pargzip, lz4 or zstd) at any point
in the future, you will need to do it in two steps.

- step #1, set `--external-compressor` and `--external-compressor-extension` flag values to empty and change `--compression-engine-name` to desired value.
- Step #2, after at least one cycle of backup with new configuration, you can set `--external-decompressor` flag value to empty.

The reason you cannot change all the values together is because the restore process will then have no way to find out which external decompressor
should be used to process the previous backup. Please make sure you have thought out all possible scenarios for restore before transitioning from one
compression engine to another.

#### Independent OLAP and OLTP transactional timeouts

`--queryserver-config-olap-transaction-timeout` specifies the timeout applied
to a transaction created within an OLAP workload. The default value is `30`
seconds, but this can be raised, lowered, or set to zero to disable the timeout
altogether.

Until now, while OLAP queries would bypass the query timeout, transactions
created within an OLAP session would be rolled back
`--queryserver-config-transaction-timeout` seconds after the transaction was
started.

As of now, OLTP and OLAP transaction timeouts can be configured independently of each
other.

The main use case is to run queries spanning a long period of time which
require transactional guarantees such as consistency or atomicity.

#### Support for specifying group information in calls to VTGate

`--grpc-use-effective-groups` allows non-SSL callers to specify groups information for a caller.
Until now, you could only specify the caller-id for the security context used to authorize queries.
As of now, you can specify the principal of the caller, and any groups they belong to.

### Online DDL changes

#### Concurrent vitess migrations

All Online DDL migrations using the `vitess` strategy are now eligible to run concurrently, given `--allow-concurrent` DDL strategy flag. Until now, only `CREATE`, `DROP` and `REVERT` migrations were eligible, and now `ALTER` migrations are supported, as well. The terms for `ALTER` migrations concurrency:

- DDL strategy must be `vitess --allow-concurent ...`
- No two migrations can run concurrently on the same table
- No two `ALTER`s will copy table data concurrently
- A concurrent `ALTER` migration will not start if another `ALTER` is running and is not `ready_to_complete`

The main use case is to run multiple concurrent migrations, all with `--postpone-completion`. All table-copy operations will run sequentially, but no migration will actually cut-over, and eventually all migrations will be `ready_to_complete`, continuously tailing the binary logs and keeping up-to-date. A quick and iterative `ALTER VITESS_MIGRATION '...' COMPLETE` sequence of commands will cut-over all migrations _closely together_ (though not atomically together).

#### vtctl command changes.
All `online DDL show` commands can now be run with a few additional parameters
- `--order` , order migrations in the output by either ascending or descending order of their `id` fields.
- `--skip`  , skip specified number of migrations in the output.
- `--limit` , limit results to a specified number of migrations in the output.

#### New syntax

The following is now supported:

```sql
ALTER VITESS_MIGRATION COMPLETE ALL
```

This works on all pending migrations (`queued`, `ready`, `running`) and internally issues a `ALTER VITESS_MIGRATION '<uuid>' COMPLETE` for each one. The command is useful for completing multiple concurrent migrations (see above) that are open-ended (`--postpone-completion`).

### Tablet Throttler

#### API changes

API endpoint `/debug/vars` now exposes throttler metrics, such as number of hits and errors per app per check type. Example:

```shell
$ curl -s http://127.0.0.1:15100/debug/vars | jq . | grep Throttler
  "ThrottlerAggregatedMysqlSelf": 0.191718,
  "ThrottlerAggregatedMysqlShard": 0.960054,
  "ThrottlerCheckAnyError": 27,
  "ThrottlerCheckAnyMysqlSelfError": 13,
  "ThrottlerCheckAnyMysqlSelfTotal": 38,
  "ThrottlerCheckAnyMysqlShardError": 14,
  "ThrottlerCheckAnyMysqlShardTotal": 42,
  "ThrottlerCheckAnyTotal": 80,
  "ThrottlerCheckMysqlSelfSecondsSinceHealthy": 0,
  "ThrottlerCheckMysqlShardSecondsSinceHealthy": 0,
  "ThrottlerProbesLatency": 355523,
  "ThrottlerProbesTotal": 74,
```

### Mysql Compatibility

#### System Settings
Vitess has had support for system settings from release 7.0 onwards, but this support came with some caveats.
As soon as a client session changes a default system setting, a mysql connection gets reserved for it.
This can sometimes lead to clients running out of mysql connections.
Users were instructed to minimize the use of this feature and to try to set the desired system settings as defaults in the mysql config.

With this release, Vitess can handle system settings changes in a much better way and clients can use them more freely.
Vitess now has the ability to pool changed settings without reserving connections for any particular session.

This feature can be enabled by setting `queryserver-enable-settings-pool` flag on the vttablet. It is disabled by default.
In future releases, we will make this flag enabled by default.

#### Lookup Vindexes

Lookup vindexes now support a new parameter `multi_shard_autocommit`. If this is set to `true`, lookup vindex dml queries will be sent as autocommit to all shards instead of being wrapped in a transaction.
This is different from the existing `autocommit` parameter where the query is sent in its own transaction separate from the ongoing transaction if any i.e. begin -> lookup query execs -> commit/rollback

### Durability Policy

#### Cross Cell

A new durability policy `cross_cell` is now supported. `cross_cell` durability policy only allows replica tablets from a different cell than the current primary to
send semi-sync ACKs. This ensures that any committed write exists in at least 2 tablets belonging to different cells.

### New EXPLAIN format

#### FORMAT=vtexplain

With this new `explain` format, you can get an output that is very similar to the command line `vtexplain` app, but from a running `vtgate`, through a MySQL query.

### VTOrc

#### Old UI Removal and Replacement

The old UI that VTOrc inherited from `Orchestrator` has been removed. A replacement UI, more consistent with the other Vitess binaries has been created.
In order to use the new UI, `--port` flag has to be provided.

Along with the UI, the old APIs have also been deprecated. However, some of them have been ported over to the new UI -

| Old API                          | New API                          | Additional notes                                                      |
|----------------------------------|----------------------------------|-----------------------------------------------------------------------|
| `/api/problems`                  | `/api/problems`                  | The new API also supports filtering using the keyspace and shard name |
| `/api/disable-global-recoveries` | `/api/disable-global-recoveries` | Functionally remains the same                                         |
| `/api/enable-global-recoveries`  | `/api/enable-global-recoveries`  | Functionally remains the same                                         |
| `/api/health`                    | `/debug/health`                  | Functionally remains the same                                         |
| `/api/replication-analysis`      | `/api/replication-analysis`      | Functionally remains the same. Output is now JSON format.             |

Apart from these APIs, we also now have `/debug/status`, `/debug/vars` and `/debug/liveness` available in the new UI.

#### Configuration Refactor and New Flags

Since VTOrc was forked from `Orchestrator`, it inherited a lot of configurations that don't make sense for the Vitess use-case.
All of such configurations have been removed.

VTOrc ignores the configurations that it doesn't understand. So old configurations can be kept around on upgrading and won't cause any issues.
They will just be ignored.

For all the configurations that are kept, flags have been added for them and the flags are the desired way to pass these configurations going forward.
The config file will be deprecated and removed in upcoming releases. The following is a list of all the configurations that are kept and the associated flags added.

|          Configurations Kept          |           Flags Introduced            |
|:-------------------------------------:|:-------------------------------------:|
|            SQLite3DataFile            |         `--sqlite-data-file`          |
|          InstancePollSeconds          |        `--instance-poll-time`         |
|    SnapshotTopologiesIntervalHours    |    `--snapshot-topology-interval`     |
|    ReasonableReplicationLagSeconds    |    `--reasonable-replication-lag`     |
|             AuditLogFile              |        `--audit-file-location`        |
|             AuditToSyslog             |         `--audit-to-backend`          |
|           AuditToBackendDB            |          `--audit-to-syslog`          |
|            AuditPurgeDays             |       `--audit-purge-duration`        |
|      RecoveryPeriodBlockSeconds       |  `--recovery-period-block-duration`   |
| PreventCrossDataCenterPrimaryFailover |    `--prevent-cross-cell-failover`    |
|        LockShardTimeoutSeconds        |        `--lock-shard-timeout`         |
|      WaitReplicasTimeoutSeconds       |       `--wait-replicas-timeout`       |
|     TopoInformationRefreshSeconds     | `--topo-information-refresh-duration` |
|          RecoveryPollSeconds          |      `--recovery-poll-duration`       |

Apart from configurations, some flags from VTOrc have also been removed -
- `sibling`
- `destination`
- `discovery`
- `skip-unresolve`
- `skip-unresolve-check`
- `noop`
- `binlog`
- `statement`
- `grab-election`
- `promotion-rule`
- `skip-continuous-registration`
- `enable-database-update`
- `ignore-raft-setup`
- `tag`

The ideal way to ensure backward compatibility is to remove the flags listed above while on the previous release. Then upgrade VTOrc.
After upgrading, remove the config file and instead pass the flags that are introduced.

#### Example Upgrade

If you are running VTOrc with the flags `--ignore-raft-setup --clusters_to_watch="ks/0" --config="path/to/config"` and the following configuration
```json
{
  "Debug": true,
  "ListenAddress": ":6922",
  "MySQLTopologyUser": "orc_client_user",
  "MySQLTopologyPassword": "orc_client_user_password",
  "MySQLReplicaUser": "vt_repl",
  "MySQLReplicaPassword": "",
  "RecoveryPeriodBlockSeconds": 1,
  "InstancePollSeconds": 1,
  "PreventCrossDataCenterPrimaryFailover": true
}
```
First drop the flag `--ignore-raft-setup` while on the previous release. So, you'll be running VTOrc with `--clusters_to_watch="ks/0" --config="path/to/config"` and the same configuration listed above.

Now you can upgrade your VTOrc version continuing to use the same flags and configurations, and it will continue to work just the same. If you wish to use the new UI, then you can add the `--port` flag as well.

After upgrading, you can drop the configuration entirely and use the new flags like `--clusters_to_watch="ks/0" --recovery-period-block-duration=1s --instance-poll-time=1s --prevent-cross-cell-failover`

#### Default Configuration Files

The default files that VTOrc searches for configurations in have also changed from `"/etc/orchestrator.conf.json", "conf/orchestrator.conf.json", "orchestrator.conf.json"` to
`"/etc/vtorc.conf.json", "conf/vtorc.conf.json", "vtorc.conf.json"`.

### Flags Restructure

#### Flags Diff

In addition to these major streams of work in release-15.0, we have made tremendous progress on [VEP-4, aka The Flag Situation](https://github.com/vitessio/enhancements/blob/main/veps/vep-4.md), reorganizing our code so that Vitess binaries and their flags are
clearly aligned in help text. An immediate win for usability, this positions us well to move on to a [viper](https://github.com/spf13/viper) implementation which will facilitate additional improvements including standardization of flag syntax and runtime configuration reloads.
We are also aligning with industry standards regarding the use of flags, ensuring a seamless experience for users migrating from or integrating with other platforms.
Below are the changes for each binary.
- [mysqlctl](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/mysqlctl.diff)
- [mysqlctld](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/mysqlctld.diff)
- [vtaclcheck](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtaclcheck.diff)
- [vtadmin](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtadmin.diff)
- [vtctlclient](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtctlclient.diff)
- [vtctld](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtctld.diff)
- [vtctldclient](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtctldclient.diff)
- [vtexplain](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtexplain.diff)
- [vtgate](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtgate.diff)
- [vtgtr](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtgtr.diff)
- [vtorc](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vtorc.diff)
- [vttablet](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vttablet.diff)
- [vttestserver](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vttestserver.diff)
- [vttlstest](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/vttlstest.diff)
- [zk](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/zk.diff)
- [zkctl](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/zkctl.diff)
- [zkctld](https://github.com/vitessio/vitess/blob/release-15.0/doc/flags/14.0-to-15.0-transition/zkctld.diff)


text:
FOUNDATION_EXPORT double Pods_skautISVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_skautISVersionString[];


text:
 .. Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you 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.

Webserver
=========

This topic describes how to configure Airflow to secure your webserver.

Rendering Airflow UI in a Web Frame from another site
------------------------------------------------------

Using Airflow in a web frame is enabled by default. To disable this (and prevent click jacking attacks)
set the below:

.. code-block:: ini

    [webserver]
    x_frame_enabled = False

Disable Deployment Exposure Warning
---------------------------------------

Airflow warns when recent requests are made to ``/robot.txt``. To disable this warning set ``warn_deployment_exposure`` to
``False`` as below:

.. code-block:: ini

    [webserver]
    warn_deployment_exposure = False

Sensitive Variable fields
-------------------------

Variable values that are deemed "sensitive" based on the variable name will be masked in the UI automatically.
See :ref:`security:mask-sensitive-values` for more details.

.. _web-authentication:

Web Authentication
------------------

By default, Airflow requires users to specify a password prior to login. You can use the
following CLI commands to create an account:

.. code-block:: bash

    # create an admin user
    airflow users create \
        --username admin \
        --firstname Peter \
        --lastname Parker \
        --role Admin \
        --email spiderman@superhero.org

It is however possible to switch on authentication by either using one of the supplied
backends or creating your own.

To deactivate the authentication and allow users to be identified as Anonymous, the following entry
in ``$AIRFLOW_HOME/webserver_config.py`` needs to be set with the desired role that the Anonymous
user will have by default:

.. code-block:: ini

    AUTH_ROLE_PUBLIC = 'Admin'

Be sure to checkout :doc:`/security/api` for securing the API.

.. note::

   Airflow uses the config parser of Python. This config parser interpolates
   '%'-signs.  Make sure escape any ``%`` signs in your config file (but not
   environment variables) as ``%%``, otherwise Airflow might leak these
   passwords on a config parser exception to a log.

Password
''''''''

One of the simplest mechanisms for authentication is requiring users to specify a password before logging in.

Please use command line interface ``airflow users create`` to create accounts, or do that in the UI.

Other Methods
'''''''''''''

Since Airflow 2.0, the default UI is the Flask App Builder RBAC. A ``webserver_config.py`` configuration file
is automatically generated and can be used to configure the Airflow to support authentication
methods like OAuth, OpenID, LDAP, REMOTE_USER.

The default authentication option described in the :ref:`Web Authentication <web-authentication>` section is related
with the following entry in the ``$AIRFLOW_HOME/webserver_config.py``.

.. code-block:: ini

    AUTH_TYPE = AUTH_DB

Another way to create users is in the UI login page, allowing user self registration through a "Register" button.
The following entries in the ``$AIRFLOW_HOME/webserver_config.py`` can be edited to make it possible:

.. code-block:: ini

    AUTH_USER_REGISTRATION = True
    AUTH_USER_REGISTRATION_ROLE = "Desired Role For The Self Registered User"
    RECAPTCHA_PRIVATE_KEY = 'private_key'
    RECAPTCHA_PUBLIC_KEY = 'public_key'

    MAIL_SERVER = 'smtp.gmail.com'
    MAIL_USE_TLS = True
    MAIL_USERNAME = 'yourappemail@gmail.com'
    MAIL_PASSWORD = 'passwordformail'
    MAIL_DEFAULT_SENDER = 'sender@gmail.com'

The package ``Flask-Mail`` needs to be installed through pip to allow user self registration since it is a
feature provided by the framework Flask-AppBuilder.

To support authentication through a third-party provider, the ``AUTH_TYPE`` entry needs to be updated with the
desired option like OAuth, OpenID, LDAP, and the lines with references for the chosen option need to have
the comments removed and configured in the ``$AIRFLOW_HOME/webserver_config.py``.

For more details, please refer to
`Security section of FAB documentation <https://flask-appbuilder.readthedocs.io/en/latest/security.html>`_.

Example using team based Authorization with Github OAuth
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
There are a few steps required in order to use team-based authorization with Github OAuth.

* configure OAuth through the FAB config in webserver_config.py
* create a custom security manager class and supply it to FAB in webserver_config.py
* map the roles returned by your security manager class to roles that FAB understands.

Here is an example of what you might have in your webserver_config.py:

.. code-block:: python

    from flask_appbuilder.security.manager import AUTH_OAUTH
    import os

    AUTH_TYPE = AUTH_OAUTH
    AUTH_ROLES_SYNC_AT_LOGIN = True  # Checks roles on every login
    AUTH_USER_REGISTRATION = (
        True  # allow users who are not already in the FAB DB to register
    )
    # Make sure to replace this with the path to your security manager class
    FAB_SECURITY_MANAGER_CLASS = "your_module.your_security_manager_class"
    AUTH_ROLES_MAPPING = {
        "Viewer": ["Viewer"],
        "Admin": ["Admin"],
    }
    # If you wish, you can add multiple OAuth providers.
    OAUTH_PROVIDERS = [
        {
            "name": "github",
            "icon": "fa-github",
            "token_key": "access_token",
            "remote_app": {
                "client_id": os.getenv("OAUTH_APP_ID"),
                "client_secret": os.getenv("OAUTH_APP_SECRET"),
                "api_base_url": "https://api.github.com",
                "client_kwargs": {"scope": "read:user, read:org"},
                "access_token_url": "https://github.com/login/oauth/access_token",
                "authorize_url": "https://github.com/login/oauth/authorize",
                "request_token_url": None,
            },
        },
    ]

Here is an example of defining a custom security manager.
This class must be available in Python's path, and could be defined in
webserver_config.py itself if you wish.

.. code-block:: python

    from airflow.www.security import AirflowSecurityManager
    import logging
    from typing import Dict, Any, List, Union
    import os

    log = logging.getLogger(__name__)
    log.setLevel(os.getenv("AIRFLOW__LOGGING__FAB_LOGGING_LEVEL", "INFO"))

    FAB_ADMIN_ROLE = "Admin"
    FAB_VIEWER_ROLE = "Viewer"
    FAB_PUBLIC_ROLE = "Public"  # The "Public" role is given no permissions
    TEAM_ID_A_FROM_GITHUB = 123  # Replace these with real team IDs for your org
    TEAM_ID_B_FROM_GITHUB = 456  # Replace these with real team IDs for your org

    def team_parser(team_payload: Dict[str, Any]) -> List[int]:
        # Parse the team payload from Github however you want here.
        return [team["id"] for team in team_payload]

    def map_roles(team_list: List[int]) -> List[str]:
        # Associate the team IDs with Roles here.
        # The expected output is a list of roles that FAB will use to Authorize the user.

        team_role_map = {
            TEAM_ID_A_FROM_GITHUB: FAB_ADMIN_ROLE,
            TEAM_ID_B_FROM_GITHUB: FAB_VIEWER_ROLE,
        }
        return list(set(team_role_map.get(team, FAB_PUBLIC_ROLE) for team in team_list))

    class GithubTeamAuthorizer(AirflowSecurityManager):

        # In this example, the oauth provider == 'github'.
        # If you ever want to support other providers, see how it is done here:
        # https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/security/manager.py#L550
        def get_oauth_user_info(
            self, provider: str, resp: Any
        ) -> Dict[str, Union[str, List[str]]]:

            # Creates the user info payload from Github.
            # The user previously allowed your app to act on their behalf,
            #   so now we can query the user and teams endpoints for their data.
            # Username and team membership are added to the payload and returned to FAB.

            remote_app = self.appbuilder.sm.oauth_remotes[provider]
            me = remote_app.get("user")
            user_data = me.json()
            team_data = remote_app.get("user/teams")
            teams = team_parser(team_data.json())
            roles = map_roles(teams)
            log.debug(
                f"User info from Github: {user_data}\n" f"Team info from Github: {teams}"
            )
            return {"username": "github_" + user_data.get("login"), "role_keys": roles}

SSL
---

SSL can be enabled by providing a certificate and key. Once enabled, be sure to use
"https://" in your browser.

.. code-block:: ini

    [webserver]
    web_server_ssl_cert = <path to cert>
    web_server_ssl_key = <path to key>

Enabling SSL will not automatically change the web server port. If you want to use the
standard port 443, you'll need to configure that too. Be aware that super user privileges
(or cap_net_bind_service on Linux) are required to listen on port 443.

.. code-block:: ini

    # Optionally, set the server to listen on the standard SSL port.
    web_server_port = 443
    base_url = http://<hostname or IP>:443

Enable CeleryExecutor with SSL. Ensure you properly generate client and server
certs and keys.

.. code-block:: ini

    [celery]
    ssl_active = True
    ssl_key = <path to key>
    ssl_cert = <path to cert>
    ssl_cacert = <path to cacert>


text:
<?php
require_once 'Base_model.php';

class Visitingrealization_model extends Base_model {

	public function __construct() {
		parent::__construct();
	}
}


text:
package sessions

import (
	"testing"

	"github.com/stretchr/testify/require"
	"github.com/surgemq/message"
)

func TestSessionInit(t *testing.T) {
	sess := &Session{}
	cmsg := newConnectMessage()

	err := sess.Init(cmsg)
	require.NoError(t, err)
	require.Equal(t, len(sess.cbuf), cmsg.Len())
	require.Equal(t, cmsg.WillQos(), sess.Cmsg.WillQos())
	require.Equal(t, cmsg.Version(), sess.Cmsg.Version())
	require.Equal(t, cmsg.CleanSession(), sess.Cmsg.CleanSession())
	require.Equal(t, cmsg.ClientId(), sess.Cmsg.ClientId())
	require.Equal(t, cmsg.KeepAlive(), sess.Cmsg.KeepAlive())
	require.Equal(t, cmsg.WillTopic(), sess.Cmsg.WillTopic())
	require.Equal(t, cmsg.WillMessage(), sess.Cmsg.WillMessage())
	require.Equal(t, cmsg.Username(), sess.Cmsg.Username())
	require.Equal(t, cmsg.Password(), sess.Cmsg.Password())
	require.Equal(t, []byte("will"), sess.Will.Topic())
	require.Equal(t, cmsg.WillQos(), sess.Will.QoS())

	sess.AddTopic("test", 1)
	require.Equal(t, 1, len(sess.topics))

	topics, qoss, err := sess.Topics()
	require.NoError(t, err)
	require.Equal(t, 1, len(topics))
	require.Equal(t, 1, len(qoss))
	require.Equal(t, "test", topics[0])
	require.Equal(t, 1, int(qoss[0]))

	sess.RemoveTopic("test")
	require.Equal(t, 0, len(sess.topics))
}

func TestSessionPublishAckqueue(t *testing.T) {
	sess := &Session{}
	cmsg := newConnectMessage()
	err := sess.Init(cmsg)
	require.NoError(t, err)

	for i := 0; i < 12; i++ {
		msg := newPublishMessage(uint16(i), 1)
		sess.Pub1ack.Wait(msg, nil)
	}

	require.Equal(t, 12, sess.Pub1ack.len())

	ack1 := message.NewPubackMessage()
	ack1.SetPacketId(1)
	sess.Pub1ack.Ack(ack1)

	acked := sess.Pub1ack.Acked()
	require.Equal(t, 0, len(acked))

	ack0 := message.NewPubackMessage()
	ack0.SetPacketId(0)
	sess.Pub1ack.Ack(ack0)

	acked = sess.Pub1ack.Acked()
	require.Equal(t, 2, len(acked))
}

func newConnectMessage() *message.ConnectMessage {
	msg := message.NewConnectMessage()
	msg.SetWillQos(1)
	msg.SetVersion(4)
	msg.SetCleanSession(true)
	msg.SetClientId([]byte("surgemq"))
	msg.SetKeepAlive(10)
	msg.SetWillTopic([]byte("will"))
	msg.SetWillMessage([]byte("send me home"))
	msg.SetUsername([]byte("surgemq"))
	msg.SetPassword([]byte("verysecret"))

	return msg
}

func newPublishMessage(pktid uint16, qos byte) *message.PublishMessage {
	msg := message.NewPublishMessage()
	msg.SetPacketId(pktid)
	msg.SetTopic([]byte("abc"))
	msg.SetPayload([]byte("abc"))
	msg.SetQoS(qos)

	return msg
}


text:
using NUnit.Framework;
using StructureMap.Building;

namespace StructureMap.Testing.Building
{
    [TestFixture]
    public class complex_concrete_build_with_child_dependencies
    {
        private Game game;

        [SetUp]
        public void SetUp()
        {
            var build = new ConcreteBuild<Game>();
            build.Constructor.Add(new ConcreteBuild<SportsTeam>()
                .ConstructorArgs("San Diego", "Chargers"));

            build.Constructor.Add(new ConcreteBuild<SportsTeam>()
                .ConstructorArgs("Kansas City", "Chiefs"));

            build.Set(x => x.Stadium, "Qualcomm Stadium");

            build.Set(x => x.Referee, new ConcreteBuild<Referee>().ConstructorArgs("John", "Smith"));

            var session = new FakeBuildSession();
            game = build.Build(session, session).As<Game>();
        }

        [Test]
        public void with_child_constructors()
        {
            game.Home.City.ShouldEqual("San Diego");
            game.Home.Mascot.ShouldEqual("Chargers");
            game.Visitor.City.ShouldEqual("Kansas City");
            game.Visitor.Mascot.ShouldEqual("Chiefs");
        }

        [Test]
        public void with_child_setter_value()
        {
            game.Stadium.ShouldEqual("Qualcomm Stadium");
        }

        [Test]
        public void with_child_setter_built_by_constructor()
        {
            game.Referee.ShouldEqual(new Referee("John", "Smith"));
        }
    }

    public class Game
    {
        private readonly SportsTeam _home;
        private readonly SportsTeam _visitor;

        public Game(SportsTeam home, SportsTeam visitor)
        {
            _home = home;
            _visitor = visitor;
        }

        public SportsTeam Home
        {
            get { return _home; }
        }

        public SportsTeam Visitor
        {
            get { return _visitor; }
        }

        public Referee Referee { get; set; }
        public string Stadium { get; set; }
    }

    public class Referee
    {
        private readonly string _first;
        private readonly string _last;

        public Referee(string first, string last)
        {
            _first = first;
            _last = last;
        }

        protected bool Equals(Referee other)
        {
            return string.Equals(_first, other._first) && string.Equals(_last, other._last);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((Referee) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((_first != null ? _first.GetHashCode() : 0)*397) ^ (_last != null ? _last.GetHashCode() : 0);
            }
        }
    }

    public class SportsTeam
    {
        private readonly string _city;
        private readonly string _mascot;

        public SportsTeam(string city, string mascot)
        {
            _city = city;
            _mascot = mascot;
        }

        public string City
        {
            get { return _city; }
        }

        public string Mascot
        {
            get { return _mascot; }
        }
    }
}


text: this is a test that ran successfully with custom options