public class ServerRequestQueue
extends java.lang.Object
The Branch SDK can queue up requests whilst it is waiting for initialization of a session to complete. This allows you to start sending requests to the Branch API as soon as your app is opened.
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsClose()
Determines whether the queue contains a session/app close request.
|
boolean |
containsInstallOrOpen()
Determines whether the queue contains an install/register request.
|
ServerRequest |
dequeue()
Removes the queued
ServerRequest object at position with index 0 within the queue,
and returns it as a result. |
void |
enqueue(ServerRequest request)
Adds a
ServerRequest object to the queue. |
static ServerRequestQueue |
getInstance(Context c)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type
ServerRequestQueue . |
int |
getSize()
Gets the number of
ServerRequest objects currently queued up for submission to
the Branch API. |
void |
insert(ServerRequest request,
int index)
As the method name implies, inserts a
ServerRequest into the queue at the index
position specified. |
void |
moveInstallOrOpenToFront(java.lang.String tag,
int networkCount)
Moves any
ServerRequest that is tagged with BranchRemoteInterface.REQ_TAG_REGISTER_INSTALL
or BranchRemoteInterface.REQ_TAG_REGISTER_INSTALL to the front of the queue. |
ServerRequest |
peek()
Gets the queued
ServerRequest object at position with index 0 within the queue, but
unlike dequeue() , does not remove it from the queue. |
ServerRequest |
peekAt(int index)
Gets the queued
ServerRequest object at position with index specified in the supplied
parameter, within the queue. |
ServerRequest |
removeAt(int index)
As the method name implies, removes the
ServerRequest object, at the position
indicated by the Integer parameter supplied. |
public static ServerRequestQueue getInstance(Context c)
Singleton method to return the pre-initialised, or newly initialise and return, a singleton
object of the type ServerRequestQueue
.
c
- A Context
from which this call was made.ServerRequestQueue
object, either fetched from a
pre-initialised instance within the singleton class, or a newly instantiated
object where one was not already requested during the current app lifecycle.public int getSize()
Gets the number of ServerRequest
objects currently queued up for submission to
the Branch API.
Integer
value indicating the current size of the List
object
that forms the logical queue for the class.public void enqueue(ServerRequest request)
Adds a ServerRequest
object to the queue.
request
- The ServerRequest
object to add to the queue.public ServerRequest dequeue()
Removes the queued ServerRequest
object at position with index 0 within the queue,
and returns it as a result.
ServerRequest
object at position with index 0 within the queue.public ServerRequest peek()
Gets the queued ServerRequest
object at position with index 0 within the queue, but
unlike dequeue()
, does not remove it from the queue.
ServerRequest
object at position with index 0 within the queue.public ServerRequest peekAt(int index)
Gets the queued ServerRequest
object at position with index specified in the supplied
parameter, within the queue. Like peek()
, the item is not removed from the queue.
index
- An Integer
that specifies the position within the queue from which to
pull the ServerRequest
object.ServerRequest
object at the specified index. Returns null if no
request exists at that position, or if the index supplied is not valid, for
instance if getSize()
is 6 and index 6 is called.public void insert(ServerRequest request, int index)
As the method name implies, inserts a ServerRequest
into the queue at the index
position specified.
request
- The ServerRequest
to insert into the queue.index
- An Integer
value specifying the index at which to insert the
supplied ServerRequest
object. Fails silently if the index
supplied is invalid.public ServerRequest removeAt(int index)
As the method name implies, removes the ServerRequest
object, at the position
indicated by the Integer
parameter supplied.
index
- An Integer
value specifying the index at which to insert the
supplied ServerRequest
object. Fails silently if the index
supplied is invalid.ServerRequest
object being removed.public boolean containsClose()
Determines whether the queue contains a session/app close request.
Boolean
value indicating whether or not the queue contains a
session close request. True if the queue contains a close request,
False if not.BranchRemoteInterface#REQ_TAG_REGISTER_CLOSE}
public boolean containsInstallOrOpen()
Determines whether the queue contains an install/register request.
Boolean
value indicating whether or not the queue contains an
install/register request. True if the queue contains a close request,
False if not.public void moveInstallOrOpenToFront(java.lang.String tag, int networkCount)
Moves any ServerRequest
that is tagged with BranchRemoteInterface.REQ_TAG_REGISTER_INSTALL
or BranchRemoteInterface.REQ_TAG_REGISTER_INSTALL
to the front of the queue.
tag
- A String
value.networkCount
- An Integer
value that indicates whether or not to insert the
request at the front of the queue or not.


Active, Environmental or Ecological Community Events
Submit an Eco Community event. Drag the blue marker to the location of the event. Notice that the coordinate of the location (latitude and longitude) is displayed in the top boxes. When at the event location, click on the blue marker and submit the event name along with the most suitable event type. Click the submit button to record the event. Other recorded events are displayed on the map as purple circles.


Database
The Database interface is an abstraction of different database libraries to allow acces do different databases (PostgreSQL and MySQL are supported).
The interface only allows easy access to the underlying database system, which will be enough in most cases. However, nearly everything you can do with the
SQL features supported by the database engine, you can do with IDatabase. IDatabase won't translate the non-standard SQL syntax from one database engine
to an other. So while they can (and maybe have to be) used, changing the underlying database engine will probably fail.
NOTE: The SQL engine used and provided by the AppPlatform is PostgreSQL. There is no mySQL server running on the AppPlatform. But because there are a
lot of servers in the world wide web (or elsewhere) running MySQL, it is supported by the AppPlatform SDK, too. For AppPlatform app developtment, normaly only
PostgreSQL knowledge is needed.
File information
Public functions
Functions to initialize
extern IDatabaseProvider * CreatePostgreSQLDatabaseProvider();
extern IDatabaseProvider * CreateMySQLDatabaseProvider();
This functions will be used to create a database provider, wich will return an instance to an IDatabase instance for the database engine to use.
Note that the returned instance must be deleted, if no longer needed.
CreatePostgreSQLDatabaseProvider
Return value
Returns a IDatabaseProvider which creates an IDatabase instance using the PostgreSQL database driver.
CreateMySQLDatabaseProvider
Return value
Returns a IDatabaseProvider which creates an IDatabase instance using the MySQL database driver.
Remarks
Because the official MySQL library doesn't support asynchronous communication, the driver itself will run in a seperate task to support
nonblocking database operations.
Helper functions
inline const char * DBErrorToStr(db_error_t err);
DBErrorToStr
Converts the given databas_error_t value to a human readable format. The result will be just a string of the name
of the enum itself. To get a real error message, call IDatabase::GetLastErrorMessage() instead.
Parameters
| db_error_t err | The error to convert to a string. |
Return value
The name of the error enum as a string.
Classes
IDatabaseProvider
class IDatabaseProvider {
public:
virtual ~IDatabaseProvider() {}
virtual class IDatabase * CreateDatabase(class IIoMux * const iomux, class UDatabase * const user, class IInstanceLog * log) = 0;
};
A database provider is needed to create an IDatabase instance. What kind of database driver used by the returned instance is defined
by the type of IDatabaseProvider itself. The IDatabase instance returned by an IDatabaseProvider must be deleted, if no longer used.
Public functions
CreateDatabase
Creates the IDatabase instance.
Parameters
| class IIoMux * const iomux | The IIoMux instance of the app. |
| class UDatabase * const user | The UDatabase instance to receive the callbacks. |
| class IInstanceLog * log | The IInstanceLog instance used for logging purposes. The flag LOG_DATABASE must be set to enable IDatabase logging. |
Return Value
The create IDatabase intsance, that must be deleted if no longer used.
IDatabase
lass IDatabase {
public:
virtual ~IDatabase() {}
virtual void Connect(const char * address, const char * dbname, const char * user, const char * password);
virtual bool Connected();
virtual void Shutdown();
virtual size_t QueryPrint(char * buffer, size_t bufferSize, const char * sqlcmd, ...);
virtual size_t QueryPrintV(char * buffer, size_t bufferSize, const char * sqlcmd, va_list argList);
virtual void ExecSQL(UDatabase * const user, dword flags, const char * sqlcmd, ...);
virtual void ExecSQLV(UDatabase * const user, dword flags, const char * sqlcmd, va_list argList);
virtual void InsertSQL(UDatabase * const user, const char * sqlcmd, ...);
virtual void InsertSQLV(UDatabase * const user, const char * sqlcmd, va_list argList);
virtual void BeginTransaction(UDatabase * const user, const char * lockTableCmd = nullptr);
virtual void EndTransaction(UDatabase * const user, bool doRollback = false);
virtual void PrepareStatement(UDatabase * user, const char * sqlcmd);
virtual void ExecSQL(UDatabase * const user, dword flags, class IPreparedStatement * const statement);
virtual void InsertSQL(UDatabase * const user, class IPreparedStatement * const statement);
virtual size_t EscapeSearchLiterals(const char * value, char * buffer, size_t bufferSize);
virtual const char * GetLastErrorMessage();
};
This is the main calss that handels the communication between the Application and the database server. The interface is primarly for executing queries while the results
of that queries need to be handled by an UDatabase instance. Each queries posted will be add to an internal queue and processed with the fifo priciple.
Queries posted during a call of BeginTransaction() and EndTransaction() will be part of that transaction. Nested transactions are not allowed.
When sending SQL queries, a user can be given to override the default user set with IDatabaseProvider::CreateDatabase(). If an other user than the default one is given
to IDatabase::BeginTransaction(), all queries posted of that user will be prioritized because of that transaction. So queries posted from other users (or with no special
user to use the default one) will be placed at the end of the queue, until the user who opens the tansaction closes it (IDatabase::EndTransaction()). This shows also a
limitation at this point: if multiple UDatabase instances as users are needed for one transaction (e. G. by starting a transaction to update a set of data from different
sources), it won't work as long as there is some kind of "master" user the other ones. Gladly there is a solution. For that case,
DatabaseSwitch can be used.
Using multiple users will also raise the question, how error handling worlks. Actually that depends on the error and how that error will
influence the internal state of IDatabase:
-
If an SQL command of a user failes, all pending commands of the user that sends that user will be removed from the internal queue.
Then the user itself will receive an UDatabase::DatabaseError(). If the user had an active transaction, IDatabase will make a rollback
and unlock tables if they are locked.
-
If an critical error occures that makes it impossible to continue using IDatabase, all pending commands of all users will be discarded. If there
is an active transaction, it will be rolled back. Then the UDatabase::DatabaseError() function will be called for all those users who had pending
queries inside the queue. After all the users had been informed, IDatabase internaly will call Shutdown() to close the database connection and
call UDatabase::DatabaseShutdown() callback of the main user.
Public functions
Connect
Establishes a connection to the database server.
Parameters
| const char * address | The address to the database server. Can be an IPv4 or IPv6 address, an URI or nullptr to connecto to the local server using much faster unix domain sockets (recommended for connecting to the PostgreSQL server on the AppPlatform). |
| const char * dbname | The name of the database to connect to. |
| const char * user | The user to use for the connection. |
| const char * dbname | The password for that user. |
Callbacks
If the connection had been established, UDatabase::DatabaseConnectComplete() will be called. If an error leads to an UDatabase::DatabaseShutdown() callback with an error code to indicate
what was going wrong.
Connected
Return value
Return true, if IDatabase is connected to the server, else false.
Remarks
After calling IDatabase::Shutdown(), Connected() will return false even if the connection to the server still exists. So Connected() cannot be used for
celanup or shutdown checks, instead handle them inside the UDatabase::DatabaseShutdown() callback.
Shutdown
Closes the database connection. If there are pending queries inside the queue, those will be handled first before the connection actually will be closed.
Callbacks
After the connection had been closed, UDatabase::DatabaseShutdown() will be called.
QueryPrint
Used to build up a query string. The query will be stored inside buffer with a maximum of bufferSize. The SQL command itself has to be passed in sqlcmd.
That string could have placeholders, which will be replaced with the values of the data given in a variable parameters list after sqlcmd. The used
placeholder must combine with the data given. Also (depending on the placeholder) some critical characters will be escaped. Using QueryPrint is an
elegant way to dynamically build up queries while preventing SQL interjection from user input at the same time.
Note that wile IDatabase::ExecSQL() does the same (which means, the SQL query with the variable parameters can directly given to ExecSQL()), QueryPrint()
helps to bild up a SQL query that can be insert into an other for nested SQL queries, or to pepare a query for later use.
Parameters
| char * buffer | The buffer to store the processed query string to. |
| size bufferSize | The size of the given buffer. |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| ... ... | Additional values for the placeholders. Must be the same order and datatypes as the placeholders defines them. |
Return value
The size of the final query string.
Remarks
The function supports the following placeholders:
- %i Placeholder for an integer
- %u Placeholder for an unsigned integer (dword)
- %f Placeholder for a floating point value (double)
- %lli Placeholder for an 64 bit integer (long64)
- %llu Placeholder for an 64 bit unsigned integer (ulong64)
- %b Placeholder for a bool
-
%q Placeholder for a string that will be copied directly, without quoting or escaping of the strings data.
Can be used to insert an alrady prepared query string.
-
%du Placeholder for a buffer. The value of the buffer will be copied as a hex string, starting with \x. Note
that an additional parameter must be passed (size_t) to tell the size of the buffer.
- %s Placeholder for a string. The string will be enclosed by '.
- %S Placeholder for a string. The string will be enclosed by ".
- %n Placeholder for a string that will be insert to the SQL command without enclosing it to ' or ".
- %e Same as %n with the exception that search literals (like _ and &) will be escaped to use them as charater and not as search wildcard.
-
%p Suffix to pass a pointer instead of a value.
Only in combination with integer or bool variants (%pi, %pu, %pb, %plli, %pllu).
When using with prepared statements, that suffix will be ignored.
Note: This can be used to set a field to NULL by pasing NULL
instead of a valid pointer. If you need to set a string field to NULL,
simply pass NULL when using %s, %S or %n.
- %% An escaped % sign.
QueryPrintV
Does the same as QueryPrint. The difference here is that a pointer to the variable parameters can be passed.
Parameters
| char * buffer | The buffer to store the processed query string to. |
| size bufferSize | The size of the given buffer. |
| const char * sqlcmd | The SQL command to execute. Can contain placeholders. |
| va_list argList | Pointer to the start of the variable parameters. |
Return value
The size of the final query string.
ExecSQL (overloaded)
Executes the given SQL command. SQL query given can contain place holders to put variable values inside the queries. Also by using that
placeholders, the values (especially strings) will be used in a way to prevent SQL interjection. The function internally calls IDatabase::QueryPrint(),
so preparing the query first and passing it to ExecSQL() actually will be a bad idea performance wise. However, in some cases QueryPrint() is still
a nice helper to prepare various queries for later use.
Note: for the placeholders and datatypes supported, look to the QueryPrint description.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| dword flags | Additional flags. Can be 0 or DB_EXEC_FETCH_ALL is supported to get all results at once (see IDataSet for details). |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| ... ... | Additional values for the placeholders. Must be the same order and datatypes as the placeholders defines them. |
Callbacks
On success, UDatabase::DatabaseExecSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
Remarks
Note that there is a limit of a maximum length for SQL commands of 250*1024-1 (255999) characters. This is the size for the finaly SQL query string,
after parsing all placeholders and inserting the values for them at the prorpriate place.
ExecSQL (overloaded)
Executes the given prepared statement. See IPreparedStatement to learn more about how to create and use them.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| dword flags | Additional flags. Can be 0 or DB_EXEC_FETCH_ALL is supported to get all results at once (see IDataSet for details). |
| IPreparedStatement * const preparedStatement | The prepared statement to execute. |
Callbacks
On success, UDatabase::DatabaseExecSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
ExecSQLV
Same as IDatabase::ExecSQL(), so that instead of a variable list of parameters for the placeholders, a pointer to the start of the variable list must be given. For more information
about the function see the describtion of IDatabase::ExecSQL() above.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| dword flags | Additional flags. Can be 0 or DB_EXEC_FETCH_ALL is supported to get all results at once (see IDataSet for details). |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| va_list argList | Pointer to the start of the variable parameters. |
Callbacks
On success, UDatabase::DatabaseExecSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
Remarks
Note that there is a limit of a maximum length for SQL commands of 250*1024-1 (255999) characters. This is the size for the finaly SQL query string,
after parsing all placeholders and inserting the values for them at the prorpriate place.
InsertSQL (overloaded)
Executes a query as a query to insert data. The difference in compartion to IDatabase::ExecSQL() is, that UDatabase::DatabaseInserSQLResult() will be called after execution,
holding the ID of the new insert dataset. The rules for the sqlcmd and the placeholder are the same as for IDatabase::ExecSQL() and IDatabse::QueryPrint(). So look to the
IDatabase::QueryPrint() description for more details. Like IDatabase::ExecSQL(), InsertSQL() calls IDatabase::QueryPrint() internally to pepare the given SQL command.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| ... ... | Additional values for the placeholders. Must be the same order and datatypes as the placeholders defines them. |
Callbacks
On success, UDatabase::DatabaseInserSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
Remarks
Note that there is a limit of a maximum length for SQL commands of 250*1024-1 (255999) characters. This is the size for the finaly SQL query string,
after parsing all placeholders and inserting the values for them at the prorpriate place.
To make it work, it is necessary that the data base table you're going to address with an InsertSQL() call, has a field named id, wich must be an 64bit, autoincrement
primary key field. Read the PostgreSQL or MySQL documentation to know how to create such a field. For PostgreSQL there is no need to add the 'RETURNING id' part to the query, because
it will be added by the InsertSQL() function.
InsertSQL (overloaded)
Executes the given prepared statement to insert data. See IPreparedStatement to learn more about how to create and use them.
The difference in compartion to IDatabase::ExecSQL() is, that UDatabase::DatabaseInserSQLResult() will be called after execution, holding the ID of the
new insert dataset.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| IPreparedStatement * const preparedStatement | The prepared statement to execute. |
Callbacks
On success, UDatabase::DatabaseInserSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
Remarks
To make it work, it is necessary that the data base table you're going to address with an InsertSQL() call, has a field named id, wich must be an 64bit, autoincrement
primary key field. Read the PostgreSQL or MySQL documentation to know how to create such a field. For PostgreSQL, the 'RETURNING id' part must be added to the query when creating
the prepared statement via IDatabase::PrepareQuery.
InsertSQLV
Same as IDatabase::InsertSQL(), so that instead of a variable list of parameters for the placeholders, a pointer to the start of the variable list must be given. For more information
about the function see the describtion of IDatabase::InsertSQL() above.
Parameters
| UDatabase * const user | The user to callback with the result of the SQL execution (or nullptr, to call the default user). |
| const char * sqlcmd | The SQL command string to process. Can contain placeholders. |
| va_list argList | Pointer to the start of the variable parameters. |
Callbacks
On success, UDatabase::DatabaseInserSQLResult() will be called, or UDatabase::DatabaseError(), if an error occures.
Remarks
Note that there is a limit of a maximum length for SQL commands of 250*1024-1 (255999) characters. This is the size for the finaly SQL query string,
after parsing all placeholders and inserting the values for them at the prorpriate place.
To make it work, it is necessary that the data base table you're going to address with an InsertSQL() call, has a field named id, wich must be an 64bit, autoincrement
primary key field. Read the PostgreSQL or MySQL documentation to know how to create such a field.
BeginTransaction
Will start a transaction block. After calling this function, all SQL queries posted by other users than the one who was given to BeginTransaction() will be
put to the and of the list (including other BeginTransaction() calls). So it is guaranteed that only the SQL queries from the user who started the transaction
will also be part of it. If nescesarry, an additional SQL command for locking a table can be given. More information about that can be found in the documentation
of PostgreSQL or MySQL. A transaction can be closed by calling IDatabase::EndTransaction().
it must be given to lockTableCmd.
Note: Never send a lock command with a normal ExecSQL, or the lock will not been
canceld if an error occures. BeginTransaction() will call LockQueue() to group the commands.
On success, UDatabase::ExecSQLResult() will be called.
Parameters
| UDatabase * const user | The user to callback with the result after starting the transaction. |
| const char * lockTableCmd | (Default: nullptr) An additional SQL command to lock tables or nullptr, if no additional command should be send. |
Callbacks
After starting the transaction, UDatabase::DatabaseBeginTransactionResult() will be called.
Remarks
If a table must be locked, only do that with IDatabase::BeginTransaction(). Never send a lock command directly using IDatabase::ExecSQL(), or the table won't be unlocked automatically!
If there are other commands in the queue, they will be processed before. So UDatabase::DatabaseBeginTransactionResult() really will be called after the transaction is active. So that
callback will be the best place to send SQL commands for that transaction.
EndTransaction
Will end a transaction. If needed, each change made during the active transaction can be rolled back when the flag is set to do so. Note that on an internal error of IDatabase
(e. g. some SQL command posted has a syntax error), the transaction automatically will be rolled back and closed. So there is no need to call EndTransaction() in case of a
database related error. If a table had been lock by IDatabase::BeginTransaction(), that table will be unlocked.
Parameters
| UDatabase * const user | The user to close the transaction for. Must be the same as given to IDatabase::BeginTransaction(). |
| bool roolBack | (Default: false) If true, IDatabase will rollback each changed made since the call of IDatabase::BeginTransaction(). |
Callbacks
After ending the transaction, UDatabase::DatabaseEndTransactionResult() will be called.
EscapeSearchLiterals
Escapes search literals used in LIKE queries so that they are not interpreted as search pattern by the database (e.g. 'Search%' will be 'Search\%' afterwards).
In PostgreSQL and MySQL, the patterns '%' and '_' are escaped. So those will be interpreted as characters. If you whant to call IDatabase::ExecSQL() or
IDatabase::InsertSQL() using a query string, it will be better to use the %e placeholder, which does the same. However, EscapeSeaerchLiterals() will come
in handy when using a string as as value for prepared statements.
Parameters
| const char * value | The string the holds (or can hold) search literals to escape. |
| const char * buffer | The buffer to store the escaped string to. |
| size_t bufferSize | The size of the buffer to store the data to. |
Remarks
The buffer given must be big enough to hold the result. So to be on the safe side, it should be able to hold strlen(value) * 2 + 1 bytes.
PrepareStatement
Creates a prepared statement for the given SQL query. See IPreparedStatement for details.
Parameters
| UDatabase * const user | The user to receive the prepared statement (or nullptr to use the default user). |
| const char * sqlcmd | The SQL command to create the prepared statment for. |
Callbacks
After creating the prepares tatement, UDatabase::DatabasePrepareStatementResult() will be called. The IPraparedStatement instance given to that callback must
be deleted if no longer needed. In case of an error, the IDatabase will call UDatabase::DatabaseError().
Remarks
For PostgreSQL, if the created perpared statement is an INSERT statement and so will be passed to IDatabase::InsertSQL(), the "RETURNING id" statement must be added to the query!
GetLastErrorMessage
Return value
Returns the error message of the last error occurred.
Remarks
GetLastErrorMessage() helps to log the error or to see what acutally was wrong. UDatabase::DatabaseError() will be a good place to call the message. Don't save the pointer
returned. Instead, of the error message should be stored for later use, you must make a copy of it.
IPreparedStatement
class IPreparedStatement {
public:
virtual ~IPreparedStatement() {}
virtual void SetParam(dword idx, int value);
virtual void SetParam(dword idx, dword value);
virtual void SetParam(dword idx, long64 value);
virtual void SetParam(dword idx, ulong64 value);
virtual void SetParam(dword idx, bool value);
virtual void SetParam(dword idx, double value);
virtual void SetParam(dword idx, int * value);
virtual void SetParam(dword idx, dword * value);
virtual void SetParam(dword idx, long64 * value);
virtual void SetParam(dword idx, ulong64 * value);
virtual void SetParam(dword idx, double * value);
virtual void SetParam(dword idx, bool * value);
virtual void SetParam(dword idx, const char * value);
virtual void SetParam(dword idx, const byte * buffer, size_t size);
};
Prepared statements are some kind of ready-to-use SQL queries. While they needs some managament overhead (create them, stored them on some place for usage
and deleted them when no longer used), they have some other advantage: ease of use and performance. As a thumb rule you can say: for
each SQL query that is used more than once on a regular basis, it is worth to use a prepared statement. Because when using prepared statment (after
creating them), there is no need to build up an SQL string, escape strings to prevent SQL injection and also there is no need to parse the SQL
string again on the database server side. So using prepared statements (while consuming a little memory footprint) can spead up the applications
performance a bit. That said, according to the documentation of PostgreSQL and MySQL, prepared statements can also have no benefit at all or even
slow down the performance under some circumstances. So finally it depends on tests. However, using prepared statements for often called SQL queries will
be a good start.
To create an IPreparedStatement instance, call IDatabase::PrepareStatement(). The instance will then passed to UDatabase::DatabasePrepareStatementResult() and must
be deleted, if no longer used. To execute a prepared statement, simply set the parameters and pass it to IDatabase::ExecSQL() or IDatabase::InsertSQL().
The index of a parameter depends on the position of the parameters place holder in the SQL string. So for a query like "select * from users where user_name=%s and
age > %i", the index of the parameter for %s will be 0, and for the parameter for %i 1. The placeholders have the same format as for IDatabase::QueryPrint(), so read
the description of that function for more information. However, because of the nature of prepared statements, there are some differences for the placeholders:
- %p will be ignored. To pass a pointer, use one of the IPreparedStatement::SetParam() functions that accept the pointer of the format needed.
- %s, %S and %n will be handled in the same way: the string will be used without beeing enclosed by ' or ".
- %s is not supported. Use %s instead and call IDatabase::EscapeSearchLiterals() to get the same effect.
After the parameters had been set and the prepared statment instance had been passed to IDatabase::ExecSQL() or IDatabase::InsertSQL(), the IPreparedStatement instance
can directly be used again and the parameters can be changed. Because the prepared statements will manage the parameters internally by reference counting so that they
are fixed as soon as the prepared statement instance sits inside the IDatabase execution queue.
Public functions
SetParam (overloaded)
Set the parameters for the query. There are various functions for the different datatypes supported by IDatabase as well as a version that accepts a pointer for that
datatype. When passing nullptr to that pointer, the datafield inside the database will be set to NULL. See the source code part above for details.
Parameters
| dword idx | The index of the parameter value to set. |
| various types value | The value for that parameter. |
Remarks
It can be that you must do some typecasting to let the compiler now, which overloaded function you actually whant to use. If e. G. SetParam() will be called with value 1,
the compiler must know, how to interpret this number: as dword, long64, bool, ...
SetParam (overloaded)
This version takes three arguments instead as two like the others. It is for passing buffers and so does also need the buffer size.
Parameters
| dword idx | The index of the parameter value to set. |
| const byte * buffer | The buffer holding the data to write to the database. |
| size_t size | The size of the buffer. |
IDataSet
class IDataSet {
public:
virtual ~IDataSet() {}
virtual size_t GetColumnCount();
virtual bool Eot();
virtual void Next();
virtual void FetchNextRow();
virtual bool IsSingleRowMode();
virtual ulong64 GetAffectedRows();
virtual const char * GetColumnName(int column);
virtual int GetColumnID(const char * columnName);
virtual bool ColumnIsNull(const char * columnName);
virtual bool ColumnIsNull(int column);
virtual int GetIntValue(const char * columnName);
virtual dword GetUIntValue(const char * columnName);
virtual long64 GetLong64Value(const char * columnName);
virtual ulong64 GetULong64Value(const char * columnName);
virtual bool GetBoolValue(const char * columnName);
virtual double GetDoubleValue(const char * columnName);
virtual const char * GetStringValue(const char * columnName);
virtual const char * GetStringValueWithNull(const char * columnName);
virtual size_t GetDataSize(const char * columnName);
virtual const byte * GetDataValue(const char * columnName);
virtual int GetIntValue(int column);
virtual dword GetUIntValue(int column);
virtual long64 GetLong64Value(int column);
virtual ulong64 GetULong64Value(int column);
virtual bool GetBoolValue(int column);
virtual double GetDoubleValue(int column);
virtual const char * GetStringValue(int column);
virtual const char * GetStringValueWithNull(int column);
virtual size_t GetDataSize(int column);
virtual const byte * GetDataValue(int column);
};
After executing a SQL query, the result of that query will given to the UDatabase user in form of an IDataSet instance. By using that instance, the data of the
query result can be accessed. After prpcessomg all data, the application must delete the IDataSet instance to let the IDatabase process the next SQL query from
the internal queue. So it is alos not allowes to store the IDataSet for some later use, because it will block the whole database system. An IDataSet with instance
will be passes to UDataset::DatabaseExecSQLResult() and should be processed before the function returns.
Public functions
GetColumnCount
Return value
Returns the number of columns available in the result set.
Eot
Return value
True, of the end of the result table had been reached, else false.
Remarks
If Eot returnes true, the IDataSet intsance must be deleted to let IDataset continue processing the next SQL query inside the internal queue.
Next
Set the internal row pointer to the next row to get the data out of it. This should be used in a loop to process all data from the query.
Please use it with care, because if processing the data takes a lot of time, it will block the whole asynchronous system for your application. Before
accessing data, IDataSet::Eot() must be called to make sure that there is data available.
Remarks
Only call Next() if the query for that result had been executed with the DB_EXEC_FETCH_ALL flag or use IDataset::FetchNextRow() instead.
FetchNextRow
Fetches the next row from the server. This is the asynchronous way of processing each row. After calling this function, UDatabase::DatabaseExecSQLResult() can be leaved
and will be called again from IDatabase, when the next row had ben read. You must check the return of IDataSet::Eot() before accessing the row data to make sure, that
there is data available.
Callbacks
UDataset::DatasetExecSQLResult() will be called
IsSingleRowMode
Can be used to check, if the data can be process with IDataSet::Next() or IDataSet::FetchNextRow(). Single-row-mode means, that the result will be fetched line by line
from the server (which is the default if the flag DB_EXEC_FETCH_ALL was not given to IDatabase::ExecSQL()).
Return value
True, if the dataset uses single-row-mode and the rows must be read calling IDataSet::FetchNextRow(). Fals, if all the rows had been received from the database server and
IDataSet::Next() must be used to process the rows.
GetAffectedRows
Return value
Returns the number of rows affected by the query (which actually is then number of rows IDataSet provides).
GetColumnName
Parameters
| int column | The index of the column to get the name for. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
Returns the name of the culumn.
GetColumnID
Parameters
| const char * columnName | The Name of the column to get the index for. |
Return value
The index of the column or -1, if the column name canot be found inside the list of columns.
ColumnIsNull (overloaded)
Parameters
| int column | The index of the column to check. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
True, if the value of the column is NULL, else false.
ColumnIsNull (overloaded)
Parameters
| const char * columnName | The name of the column to check. |
Return value
True, if the value of the column is NULL, else false.
GetIntValue (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as integer.
GetIntValue (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as integer.
GetUIntValue (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as integer.
GetUIntValue (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as dword.
GetLong64Value (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as long64.
GetLong64Value (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as long64.
GetULong64Value (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as ulong64.
GetULong64Value (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as ulong64.
GetBoolValue (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as bool.
GetBoolValue (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as bool.
GetDoubleValue (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as double.
GetDoubleValue (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as doubel.
GetStringValue (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as string. If the column is NULL, an empty string will be returned.
GetStringValue (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as string. If the column is NULL, an empty string will be returned.
GetStringValueWithNull (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as string. If the column is NULL, nullptr will be returned.
GetStringValueWithNull (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The data value of the column as string. If the column is NULL, nullptr will be returned.
GetDataSize (overloaded)
Parameters
| int column | The index of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
The number of binary data bytes hold by the column.
Remarks
To get the binary data itself, call IDataSet::GetDataValue().
GetDataSize (overloaded)
Parameters
| const char * columnName | The name of the column get the value from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
The number of binary data bytes hold by the column.
Remarks
To get the binary data itself, call IDataSet::GetDataValue().
GetDataValue (overloaded)
Parameters
| int column | The index of the column get the data from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Return value
Returns the binary data of the column.
Remarks
Got get the number of bytes hold by the column, call IDataSet::GetDataSize().
GetDataValue (overloaded)
Parameters
| const char * columnName | The name of the column get the data from. Must be between 0 and IDataSet::GetColumnCount() - 1. |
Returns the binary data of the column.
Remarks
Got get the number of bytes hold by the column, call IDataSet::GetDataSize().
UDatabase
class UDatabase {
public:
virtual void DatabaseConnectComplete(IDatabase * const database) {};
virtual void DatabaseShutdown(IDatabase * const database, db_error_t reason) {};
virtual void DatabaseError(IDatabase * const database, db_error_t error) = 0;
virtual void DatabaseExecSQLResult(IDatabase * const database, class IDataSet * dataset) {};
virtual void DatabaseInsertSQLResult(IDatabase * const database, ulong64 id) {};
virtual void DatabaseBeginTransactionResult(IDatabase * const database) {};
virtual void DatabaseEndTransactionResult(IDatabase * const database) {};
virtual void DatabasePrepareStatementResult(IDatabase * const database, class IPreparedStatement * statement) {};
};
Each database request will lead to a result, wich will be redirected to an UDatabase instance. An app must provide at least on UDatabase instance to pass to IDatabase, but
also can have multiple UDatabase objects to pass to database related calls. That user passed to a function (like IDatabase::ExecSQL()) will receive the result of the SQL
query to execute. If nullptr will be passed as user to that functions, the default user (given to IDatabaseProvider::CreateDatabase()) will be used for callbacks.
Public functions
DatabaseConnectComplete
Will be called when the connection to the database server had been established.
Parameters
| IDatabase * const database | The calling database instance. |
DatabaseShutdown
Will be called after the connection had been closed or if an error occurred when tried to establish the connection. The reason provides details
about what happend.
Parameters
| IDatabase * const database | The calling database instance. |
| db_error_t reason | The reason why the connection had been closed. |
Remarks
This callback will be a good place to delete the IDatabase instance. However, this should only be done from the same UDatabase instance that
was given to IDatabaseProvider::CreateDatabase().
DatabaseError
Will be called when an error occures while executing a command. The user whis query raised an error will receive that callback. In that case, all
pending SQL queries inside the internal queue of IDatabase will be discared and an active transaction will be be rolled back and closed (befor this callback raises).
If a critical error occures, all queries inside the queue will be discared and all users will receive UDatabase::DatabaseError(), before the main user receives
a UDatabase::DatabaseShutdown().
Parameters
| IDatabase * const database | The calling database instance. |
| db_error_t error | The rror that occured. |
DatabaseExecSQLResult
Will be called after executing an SQL query, providing the result of that call. The given dataset should be handled here and must be deleted,
if no longer needed to let IDatabase process the next query of the internal queue. If the dataset is in sinngle row mode (because of fetching each
row in an asynchronous way), DatabaseExecSQLResult() will be recalled after receiving the next row. For this, IDataSet::FetchNextRow() must be used.
Parameters
| IDatabase * const database | The calling database instance. |
| IDataset * dataset | The IDataset instance providing the result of the query. |
Remarks
Don't delete the IDataset after calling IDataset::FetchNextRow(). Also, don't forget to delete the IDataSAet instance if you no longer
need it, of the database system will block forever.
DatabaseInsertSQLResult
Will be called after the execution of IDatabase::InsertSQL(), providing the id of the newly insert row.
Parameters
| IDatabase * const database | The calling database instance. |
| ulong64 id | The ID of the new insert row. |
Remarks
To use IDatabse::InsertSQL() and this callback, the table to insert a row must provide a field named ID. That field must
hold a 64bit value and must be defined to autoincrement. More information can be found in the PostgreSQL or MySQL documentation.
DatabaseBeginTransactionResult
Will be called after a transaction had been started because of a previous call to IDatabase::BeginTransaction(). So this callback will be the right
place to start posting SQL requests that will be part of the transaction.
Parameters
| IDatabase * const database | The calling database instance. |
Remarks
After a transaction had been started, all IDatabase::ExecSQL() or IDatabase::InsertSQL() calls will be put to the end of the queue and ignroed, if
they are not for the same user as the one who started the transaction. To use multiple users for results of transaction queries, use the
DatabaseSwitch helper class.
DatabaseEndTransactionResult
Will be called after a transaction had been closed because of a previous call to IDatabase::EndTransaction().
Parameters
| IDatabase * const database | The calling database instance. |
DatabasePrepareStatementResult
When creating a prepared statement by calling IDatabase::PrepareStatement(), the result will be passed to UDatabase::DatabasePrepareStatementResult() by the
given IPreparedStatement instance. To execute that instance, it must be given to IDatabase::ExecSQL() or IDatabase::InsertSQL(). It also must be deleted by
the app, if no longer used.
Parameters
| IDatabase * const database | The calling database instance. |
| IPreparedStatement * statement | The instance to use for executing the prepared statement. |
Data types
Defines / Statics
#define DB_EXEC_FETCH_ALL 0x01
| DB_EXEC_FETCH_ALL | Can be passed to IDatabase::ExecSQL() to request all result rows. In that case, the results will be completely loaded into the apps
memory. To access it, the data must be processed in a loop by calling IDataSet::Next(). |
db_error_t
typedef enum {
DB_OK = 0,
DB_SHUTDOWN_NORMAL = DB_OK,
DB_ERR_CONNECT_FAILED,
DB_ERR_SQL_COMMAND_FAILED,
DB_ERR_SHUTDOWN_STATE,
DB_ERR_SERVER_ERROR
} db_error_t;
This enum is used determine the reason why a database connection had been closed. The values are:
| DB_OK | Everything is fine, the shutdown is the result of a previous IDatabase::Shutdown() call. |
| DB_SHUTDOWN_NORMAL | Same as DB_OK. Recommendet to use for better readable code. |
| DB_ERR_CONNECT_FAILED | The conenction to the database failed. Enable logging to get details. |
| DB_ERR_SQL_COMMAND_FAILED | An SQL command send failed to execute. Enable logging to see what was wrong with that query. |
| DB_ERR_SHUTDOWN_STATE | The app tried to execute a database command, while the shutdown of the database already is in process. |
| DB_ERR_SERVER_ERROR | An error occured on the database server side. Enable logging to see more details. |
Code Example
app::app(IIoMux * iomux)
: iomux(iomux)
{
IDatabaseProvider * databaseProvider = CreatePostgreSQLDatabaseProvider();
this->database = databaseProvider->CreateDatabase(iomux, this, this);
delete databaseProvider;
this->database->Connect("<IP_ADDRESS>", "test_db", "user", "12345");
}
void app::DatabaseConnectComplete(IDatabase * const database)
{
this->database->ExecSQL(this, 0, "select * from test_table where name=%s and id=%u", "Noname", 42);
}
void app::DatabaseExecSQLResult(IDatabase * const database, class IDataSet * dataset)
{
if (dataset->Eot()) {
delete dataset;
this->database->Shutdown();
}
else {
printf("%u | %s\n", dataset->GetIntValue("id"), dataset->GetStringValue("name"));
dataset->FetchNextRow();
}
}
void app::DatabaseShutdown(IDatabase * const database, db_error_t reason)
{
if (reason != DB_SHUTDOWN_NORMAL) {
debug->printf("An error occured, look at the log of the app\n");
}
delete this->database;
this->database = nullptr;
}


Match Play. Red trails 2-6 to 11. How should Red play 61?
pips Red=142 White=127
(CorrectAnswer= 0/0, ErrorScore= 0)
This is a close call, but the long-term asset created with 13/7, 8/7 is marginally better than running for home with 24/17. Given that Red trails in the race this looks like the logical play.
24/17 is a small mistake.
24/17 is a small mistake.
1. Cubeful 2-ply 13/7 8/7 Eq.: -0.498 0.365 0.059 0.002 - 0.635 0.242 0.007 2. Cubeful 2-ply 24/17 Eq.: -0.579 (-0.081) 0.352 0.042 0.001 - 0.648 0.252 0.003 3. Cubeful 2-ply 24/23 8/2 Eq.: -0.649 (-0.151) 0.333 0.056 0.002 - 0.667 0.306 0.006 4. Cubeful 2-ply 10/9 10/4 Eq.: -0.673 (-0.175) 0.317 0.054 0.001 - 0.683 0.269 0.005 5. Cubeful 0-ply 8/1 Eq.: -0.738 (-0.240) 0.307 0.055 0.001 - 0.693 0.289 0.006


How do I make this list unique?
UKUSABangladeshIndia
And how do I filter the records below based on the selected items above? (multiple select)


Crucible
Crucible is an extension of Skyline based on Abe Stanway’s Crucible testing suite. Crucible has been integrated into Skyline as a module and daemon to allow for the following:
Allowing for the ad-hoc analysis of a time series and generation of resultant resources (e.g. plot images, etc).
Allowing for the ad-hoc analysis of a time series by a specific or adhoc defined algorithm and generation of resultant resources (e.g. plot images, etc).
For storing the individual time series data for triggered anomalies.
Be forewarned that Crucible can generated a substantial amount of data in the time series json archives, especially if it is enabled in any of the following contexts:
It should not be enabled in any of the any settings unless it is for development or testing purposes.
Usage
Crucible is not meant for generic Analyzer, Mirage or Boundary inputs although it does works and was patterned using data fed to it from Analyzer. Crucible is aimed at having the ability to add miscellaneous time series and algorithms in an ad-hoc manner. Enabling the use of data sources other than Graphite and Redis data for testing or anomaly detecting on and for testing algorithms in an ad-hoc manner as well.
Crucible is enabled by default in its own settings block in settings.py
, but
it disabled default in each of the abovementioned app settings.
Manually creating check files
To analyze metrics or data on an ad-hoc basis, Crucible needs to be initiated with a check file. The check file contains variables instructing Crucible what to check.
The crucible check file has the following lines, each line being a variable:
metric [required] - the metric name
value [required] - the anomalous value or 0
from_timestamp [required] - the from unix timestamp for Graphite, can be 0 if the graphite_metric and graphite_override_uri_parameters are passed with the timestamp
metric_timestamp [required] - the from unix timestamp for Graphite, can be 0 if the graphite_metric and graphite_override_uri_parameters are passed with the timestamp
algorithms [optional] - what algorithms to run, if not passed defaults to [‘all’] which runs all Skyline algorithms define in
settings.ALGORITHMS
and theskyline.crucible.crucible_algorithms.detect_drop_off_cliff
algorithm.anomaly_dir [required] - the directory in which to find the data and save outputted resources. It will be created if it does not exist.
graphite_metric [optional] - True or False
run_crucible_tests [optional] - True or False
added_by [optional] - string
graphite_override_uri_parameters [optional] - str or False, default is False if set to a str the graphite_metric must be set to True too.
If the graphite_override_uri_parameters variable is set in the check file the graphite_metric variable must be set to True for it be take effect. If the graphite_override_uri_parameters is set Crucible will ignore the from_timestamp and until_timestamp and use the passed graphite_override_uri_parameters URI parameters. graphite_override_uri_parameters can be set to surface any Graphite metric with any Graphite function/s applied. An example of a graphite_override_uri_parameters would be:
`"from=00%3A00_20190527&until=23%3A59_20190612&target=movingMedian(nonNegativeDerivative(stats.machine-1.vda.readTime)%2C24)"`
The full graphite URL and render URI parameter must not be declared as Crucible will construct the full URL using normal settings.py GRAPHITE variables.
Here are some examples of check files, the format has change between the Python 2 and 3 versions.
Example of current Python 3 format:
metric = 'telegraf.skyline-1.cpu-total.cpu.usage_user'
value = '0'
from_timestamp = '1577504411'
metric_timestamp = '1585394411'
triggered_algorithms = ['histogram_bins', 'first_hour_average', 'stddev_from_average', 'grubbs', 'ks_test', 'mean_subtraction_cumulation', 'median_absolute_deviation', 'stddev_from_moving_average', 'least_squares']
algorithms = ['histogram_bins', 'first_hour_average', 'stddev_from_average', 'grubbs', 'ks_test', 'mean_subtraction_cumulation', 'median_absolute_deviation', 'stddev_from_moving_average', 'least_squares', 'detect_drop_off_cliff']
anomaly_dir = '/tmp/crucible_testing/crucible'
graphite_metric = True
run_crucible_tests = True
added_by = 'earthgecko'
graphite_override_uri_parameters = 'from=-3months&target=telegraf.skyline-1.cpu-total.cpu.usage_user'
The creation of the above can be automated fairly easily assuming you are running Skyline as the skyline user, to analyze the last 3 months of data in Graphite for a metric:
METRIC="telegraf.skyline-1.cpu-total.cpu.usage_user"
WDIR="/tmp/crucible_testing/crucible/$METRIC"
mkdir -p $WDIR
UNTIL=$(date +%s)
FROM=$(echo "$UNTIL - 7890000" | bc)
echo "metric = '$METRIC'
value = '0'
from_timestamp = '$FROM'
metric_timestamp = '$UNTIL'
triggered_algorithms = ['histogram_bins', 'first_hour_average', 'stddev_from_average', 'grubbs', 'ks_test', 'mean_subtraction_cumulation', 'median_absolute_deviation', 'stddev_from_moving_average', 'least_squares']
algorithms = ['histogram_bins', 'first_hour_average', 'stddev_from_average', 'grubbs', 'ks_test', 'mean_subtraction_cumulation', 'median_absolute_deviation', 'stddev_from_moving_average', 'least_squares', 'detect_drop_off_cliff']
anomaly_dir = '$WDIR'
graphite_metric = True
run_crucible_tests = True
added_by = 'earthgecko'
graphite_override_uri_parameters = 'from=-3months&target=${METRIC}'" > $WDIR/$METRIC.txt
chown -R skyline:skyline $WDIR
cat $WDIR/$METRIC.txt > /opt/skyline/crucible/check/$METRIC.txt
chown skyline:skyline /opt/skyline/crucible/check/$METRIC
systemctl start crucible
Example of the old Python 2 format:
metric = "stats.machine-1.vda.readTime"
value = "123.24"
from_timestamp = "1558911600"
metric_timestamp = "1560380399"
algorithms = ["histogram_bins", "first_hour_average", "stddev_from_average", "grubbs", "ks_test", "mean_subtraction_cumulation", "median_absolute_deviation", "stddev_from_moving_average", "least_squares"]
anomaly_dir = "/opt/skyline/mirage/data/stats.machine-1.vda.readTime"
graphite_metric = True
run_crucible_tests = True
added_by = "earthgecko"
graphite_override_uri_parameters = "from=00%3A00_20190527&until=23%3A59_20190612&target=movingMedian(nonNegativeDerivative(stats.zpf-watcher-prod-1-30g-doa2.vda.readTime)%2C24)"
Why use .txt check files
The rationale behind offloading checks.
A number of the Skyline daemons create txt check and metadata files, and json time series files.
For example Analyzer creates txt check files for Mirage, Crucible and Panorama. These txt files are created in logical directory structures that mirror Graphite’s whisper storage directories for stats, etc. Often other time series data sets that are not Graphite, machine or app related metrics, are also structured in a directory or tree structure and follow similar naming convention, which allows for this tree and txt files design to work with a large number of other time series data sets too.
Although there is an argument that checks and their related metadata could also be queued through Redis or another queue application, using the local filesystem is the simplest method to pass data between the Skyline modules, without introducing additional dependencies.
While ensuring that Redis is being queried as minimally as required to do analysis. The shuffling of data and querying of “queues” is offloaded to the filesystem. Resulting in each module being somewhat autonomous in terms of managing its own work, decoupled from the other modules.
Today’s filesystems are more than capable of handling this load. The use of txt files also provides an event history, which transient Redis data does not.
Importantly in terms of Crucible ad-hoc testing, txt and json time series files provide a simple and standardised method to push ad-hoc checks into Crucible.
What Crucible does
Crucible has 3 roles:
Store resources (timeseries json and graph pngs) for triggered anomalies.
Run ad-hoc analysis on any timeseries and create matplotlib plots for the run algorithms.
To update the Panorama database (tbd for future Panorama branch)
Crucible can be used to analyse any triggered anomaly on an ad-hoc basis. The timeseries is stored in gzipped json for triggered anomalies so that retrospective full analysis can be carried out on a snapshot of the timeseries as it was when the trigger/s fired without the timeseries being changed by aggregation and retention operations.
Crucible can create a large amount of data files and require significant disk space.


LUATEX(1) Web2C @VERSION@ LUATEX(1) NAME luatex, texlua, texluac - An extended version of pdfTeX using Lua as an embedded scripting language SYNOPSIS luatex [--lua=FILE] [OPTION]... [TEXNAME[.tex]] [COMMANDS] luatex [--lua=FILE] [OPTION]... \FIRST-LINE luatex [--lua=FILE] [OPTION]... &FMT ARGS DESCRIPTION Run the luaTeX typesetter on TEXNAME, usually creating TEXNAME.pdf. Any remaining COMMANDS are processed as luaTeX input, after TEXNAME is read. Alternatively, if the first non-option argument begins with a backslash, interpret all non-option arguments as a line of luaTeX input. Alternatively, if the first non-option argument begins with a &, the next word is taken as the FMT to read, overriding all else. Any remaining arguments are processed as above. If no arguments or options are specified, prompt for input. If called as texlua it acts as lua interpreter. If called as texluac it acts as lua bytecode compiler. LuaTeX is an extended version of pdfTeX with Unicode and OpenType font support, embeded Lua scripting language, the e-TeX and Omega extensions, as well as integrated MetaPost engine, that can create PDF files as well as DVI files. For more information about luatex, see http://www.lua‐ tex.org, you can read LuaTeX manual using texdoc utility (texdoc luatex). All LuaTeX text input and output is considered to be Unicode text. In DVI mode, luaTeX can be used as a complete replacement for the TeX engine. In PDF mode, luaTeX can natively handle the PDF, JPG, JBIG2, and PNG graphics formats. luaTeX cannot include PostScript or Encapsulated Post‐ Script (EPS) graphics files; first convert them to PDF using epstopdf (1). OPTIONS When the LuaTeX executable starts, it looks for the --lua commandline option. If there is no --lua option, the commandline is interpreted in a similar fashion as in traditional pdfTeX and Aleph. But if the option is present, LuaTeX will enter an alternative mode of commandline parsing in comparison to the standard web2c programs. The presence of --lua makes most of other options unreliable, because the lua initialization file can disable kpathsea and/or hook functions into various callbacks. --lua=FILE The lua initialization file. The following two options alter the executable behaviour: --luaonly Start LuaTeX as a Lua interpreter. In this mode, it will set Lua's arg[0] to the found script name, pushing preceding options in negative values and the rest of the commandline in the positive values, just like the Lua interpreter. LuaTeX will exit immedi‐ ately after executing the specified Lua script. --luaconly Start LuaTeX as a Lua byte compiler. In this mode, LuaTeX is exactly like luac from the standalone Lua distribution, except that it does not have the -l switch, and that it accepts (but ignores) the --luaconly switch. Then the regular web2c options: --debug-format Debug format loading. --draftmode Sets \pdfdraftmode so luaTeX doesn't write a PDF and doesn't read any included images, thus speeding up execution. --enable-write18 Synonym for --shell-escape. --disable-write18 Synonym for --no-shell-escape. --shell-escape Enable the \write18{command} construct, and Lua functions os.exe‐ cute(), os.exec(), os.spawn(), and io.popen(). The command can be any shell command. This construct is normally disallowed for security reasons. --no-shell-escape Disable the \write18{command} construct and the other Lua func‐ tions, even if it is enabled in the texmf.cnf file. --shell-restricted Enable restricted version of \write18, os.execute(), os.exec(), os.spawn(), and io.popen(), only commands listed in texmf.cnf file are allowed. --file-line-error Print error messages in the form file:line:error which is similar to the way many compilers format them. --no-file-line-error Disable printing error messages in the file:line:error style. --fmt=FORMAT Use FORMAT as the name of the format to be used, instead of the name by which luaTeX was called or a %& line. --help Print help message and exit. --ini Start in INI mode, which is used to dump formats. The INI mode can be used for typesetting, but no format is preloaded, and basic initializations like setting catcodes may be required. --interaction=MODE Sets the interaction mode. The MODE can be either batchmode, nonstopmode, scrollmode, and errorstopmode. The meaning of these modes is the same as that of the corresponding \commands. --jobname=NAME Use NAME for the job name, instead of deriving it from the name of the input file. --kpathsea-debug=BITMASK Sets path searching debugging flags according to the BITMASK. See the Kpathsea manual for details. --mktex=FMT Enable mktexFMT generation, where FMT must be either tex or tfm. --nosocket Disable the luasocket (network) library. --output-comment=STRING In DVI mode, use STRING for the DVI file comment instead of the date. This option is ignored inPDF mode. --output-directory=DIRECTORY Write output files in DIRECTORY instead of the current directory. Look up input files in DIRECTORY first, then along the normal search path. --output-format=FORMAT Set the output format mode, where FORMAT must be either pdf or dvi. This also influences the set of graphics for‐ mats understood by luaTeX. --progname=NAME Pretend to be program NAME (only for kpathsea). --recorder Enable the filename recorder. This leaves a trace of the files opened for input and output in a file with extension .fls. --safer Disable some Lua commands that can easily be abused by a malicious document. --synctex=NUMBER Enable/disable SyncTeX extension. --version Print version information and exit. --credits Print credits and version details.  SEE ALSO pdftex(1), etex(1), aleph(1), omega(1), lua(1). AUTHORS The primary authors of LuaTeX are Hartmut Henkel, Taco Hoekwater, and Hans Hagen, with help from Martin Schröder, Karel Skoupy, and Han The Thanh. TeX was designed by Donald E. Knuth, who implemented it using his Web system for Pascal programs. It was ported to Unix at Stanford by Howard Trickey, and at Cornell by Pavel Curtis. The version now offered with the Unix TeX distribution is that generated by the Web to C system (web2c), originally written by Tomas Rokicki and Tim Morgan. luatex 0.40 2009.04.22 LUATEX(1)


|
QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.30
|
Curve state for Libor market models More...
#include <ql/models/marketmodels/curvestates/lmmcurvestate.hpp>
Public Member Functions | |
| LMMCurveState (const std::vector< Time > &rateTimes) | |
Modifiers | |
| void | setOnForwardRates (const std::vector< Rate > &fwdRates, Size firstValidIndex=0) |
| void | setOnDiscountRatios (const std::vector< DiscountFactor > &discRatios, Size firstValidIndex=0) |
| Public Member Functions inherited from CurveState | |
| CurveState (const std::vector< Time > &rateTimes) | |
| virtual | ~CurveState ()=default |
| Size | numberOfRates () const |
| const std::vector< Time > & | rateTimes () const |
| const std::vector< Time > & | rateTaus () const |
| Rate | swapRate (Size begin, Size end) const |
Inspectors | |
| Size | first_ |
| std::vector< DiscountFactor > | discRatios_ |
| std::vector< Rate > | forwardRates_ |
| std::vector< Rate > | cmSwapRates_ |
| std::vector< Real > | cmSwapAnnuities_ |
| std::vector< Rate > | cotSwapRates_ |
| std::vector< Real > | cotAnnuities_ |
| Size | firstCotAnnuityComped_ |
| Real | discountRatio (Size i, Size j) const override |
| Rate | forwardRate (Size i) const override |
| Rate | coterminalSwapRate (Size i) const override |
| Rate | coterminalSwapAnnuity (Size numeraire, Size i) const override |
| Rate | cmSwapRate (Size i, Size spanningForwards) const override |
| Rate | cmSwapAnnuity (Size numeraire, Size i, Size spanningForwards) const override |
| const std::vector< Rate > & | forwardRates () const override |
| const std::vector< Rate > & | coterminalSwapRates () const override |
| const std::vector< Rate > & | cmSwapRates (Size spanningForwards) const override |
| std::unique_ptr< CurveState > | clone () const override |
Additional Inherited Members | |
| Protected Attributes inherited from CurveState | |
| Size | numberOfRates_ |
| std::vector< Time > | rateTimes_ |
| std::vector< Time > | rateTaus_ |
Curve state for Libor market models
This class stores the state of the yield curve associated to the fixed calendar times within the simulation. This is the workhorse discounting object associated to the rate times of the simulation. It's important to pass the rates via an object like this to the product rather than directly to make it easier to switch to other engines such as a coterminal swap rate engine. Many products will not need expired rates and others will only require the first rate.
Definition at line 39 of file lmmcurvestate.hpp.
|
explicit |
Definition at line 28 of file lmmcurvestate.cpp.
| void setOnDiscountRatios | ( | const std::vector< DiscountFactor > & | discRatios, |
| Size | firstValidIndex = 0 |
||
| ) |
Implements CurveState.
Definition at line 98 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 105 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 138 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 111 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 165 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 150 of file lmmcurvestate.cpp.
|
overridevirtual |
Implements CurveState.
Definition at line 177 of file lmmcurvestate.cpp.
|
overridevirtual |
Implements CurveState.
Definition at line 182 of file lmmcurvestate.cpp.
Implements CurveState.
Definition at line 190 of file lmmcurvestate.cpp.
|
overridevirtual |
Implements CurveState.
Definition at line 198 of file lmmcurvestate.cpp.
|
private |
Definition at line 78 of file lmmcurvestate.hpp.
|
private |
Definition at line 79 of file lmmcurvestate.hpp.
|
private |
Definition at line 80 of file lmmcurvestate.hpp.
|
mutableprivate |
Definition at line 81 of file lmmcurvestate.hpp.
|
mutableprivate |
Definition at line 82 of file lmmcurvestate.hpp.
|
mutableprivate |
Definition at line 83 of file lmmcurvestate.hpp.
|
mutableprivate |
Definition at line 84 of file lmmcurvestate.hpp.
|
mutableprivate |
Definition at line 86 of file lmmcurvestate.hpp.


Black Friday Deal from Yubico to help you protect your data
by Phil TannBlack Friday is fast approaching and we’ll undoubtedly be seeing a lot of tech specials as the time nears. One that has landed in my email is from Yubico for their Yubikey USB 2FA devices.
We’ve covered data protection, strong passwords and 2 Factor Authentication a lot here at Ausdroid and most recently we took a quick look at the soon to be released biometric capable Yubikey.
 Don’t ask what it’s going to cost you to set up, ask what it could cost you if you lose your account or access to your valuable data.
With Black Friday approaching Yubico are offering some great deals between November 25th and December 2nd on the Yubico site:
Get $20 OFF any 2 keys (including 2 packs) from the YubiKey 5 Series or if you’re looking at a larger investment for your business or family, you can get $100 when you spend $400 or more on the same series of keys.
If you’re interested in upping your security game, these are well worth the investment.


DBC has had us reflecting on our values this week. The one I wanted to hone in on is enthusiasm. I feel like sales people have something internally that helps them cope with ups and downs and I think most of it can be attributed to enthusiasm and optimism.
Enthusiasm has opened every door thus far for me. At some point in life, someone has to give you a chance; They have to take a risk on you. And people would rather take a risk on someone enthusiastic, eager, and optimistic if everything else is the same. Early on in my sales career, I sat in on an advanced sales training session and the speaker, who was a phenomenal sales person, said the best advice he ever got was from someone who told him, "it's hard to say no to a smiling idiot."
The last piece of advice I gave was to an old friend who came back to Berkeley after going back to grad school. We had both experienced a really traumatic experience in college and although many of those involved had moved on, she did not because she had been away. With all the emotions and conflict she was feeling, she asked me on how I had coped and moved on. I spoke a lot into having hope, faith, and a strong sense of identity in order to make the right decision. It's removing the fantasy of a perfect ending but still remaining optimistic, that even through trials, that something meaningful and significant will come of it.
Through my experience working in sales and going door-to-door, I found that positive affirmations are essential to maintaining my level of confidence. In fact, after doing it for so long, I feel like it's become a habit; second-nature to my day-to-day. I believe this will help me overcome some of the adverse moments at DBC.   It's powerful. It works. And I wish more people did it in their day-to-day.


class COCODataArchive(_td.StrList):
Known subclasses: cocopp.archiving.COCOBBOBBiobjDataArchive
, cocopp.archiving.COCOBBOBDataArchive
, cocopp.archiving.COCOBBOBNoisyDataArchive
Data archive based on an archive definition file.
This class is not meant to be instantiated directly. Instead, use
cocopp.archiving.get
to get a class instance. The class needs an
archive definition file to begin with, as created with
cocopp.archiving.create
.
See cocopp.archives
or cocopp.archiving.official_archives
for the
"official" archives.
This class "is" a list
(StrList
) of names which are relative file
names separated with slashes "/". Each name represents the zipped data
from a full archived experiment, benchmarking one algorithm on an
entire benchmark suite.
The function create
serves to create a new user-defined archive from
experiment data which can be loaded with get
. Other derived classes define
other specific (sub)archives.
Calling the class instance (alias to find
) helps to extract entries
matching one or several substrings, e.g. a year or a method.
find_indices
returns the respective indices instead of the names.
print
displays both. For example:
>>> import cocopp >>> cocopp.archives.bbob.find('bfgs') # doctest:+SKIP ['2009/BFGS_ros_noiseless.tgz', '2012/DE-BFGS_voglis_noiseless.tgz', '2012/PSO-BFGS_voglis_noiseless.tgz', '2014-others/BFGS-scipy-Baudis.tgz', '2014-others/L-BFGS-B-scipy-Baudis.tgz'...
To post-process these data call:
>>> cocopp.main(cocopp.archives.bbob.get_all('bfgs')) # doctest:+SKIP
Method get
downloads a single "matching" data set if necessary and
returns the absolute data path which can be used with
cocopp.main
.
Method index
is inherited from list
and finds the index of the
respective name entry in the archive (exact match only).
cocopp.archives.all
contains all experimental data for all test
suites.
>>> import cocopp >>> bbob = cocopp.archives.bbob # the bbob testbed archive >>> len(bbob) > 150 True
>>> bbob[:3] # doctest:+ELLIPSIS,+SKIP, ['2009/... >>> bbob('2009/bi')[0] # doctest:+ELLIPSIS,+SKIP, '...
Get a list
of already downloaded data full pathnames or None
:
>>> [bbob.get(i, remote=False) for i in range(len(bbob))] # doctest:+ELLIPSIS [...
Find something more specific:
>>> bbob('auger')[0] # == bbob.find('auger')[0] # doctest:+SKIP, '2009/CMA-ESPLUSSEL_auger_noiseless.tgz'
corresponds to cocopp.main('auger!').
>>> bbob.index('2009/CMA-ESPLUSSEL_auger_noiseless.tgz') # just list.index 5
>>> data_path = bbob.get(bbob(['au', '2009'])[0], remote=False) >>> assert data_path is None or str(data_path) == data_path
These commands may download data, to avoid this the option remote=False is given:
>>> ' '.join(bbob.get(i, remote=False) or '' for i in [2, 13, 33]) # can serve as argument to cocopp.main # doctest:+ELLIPSIS,+SKIP, '... >>> bbob.get_all([2, 13, 33], remote=False).as_string # is the same # doctest:+ELLIPSIS,+SKIP, ' ... >>> ' '.join(bbob.get(name, remote=False) for name in [bbob[2], bbob[13], bbob[33]]) # is the same # doctest:+ELLIPSIS,+SKIP, '... >>> ' '.join(bbob.get(name, remote=False) for name in [ ... '2009/BAYEDA_gallagher_noiseless.tgz', ... '2009/GA_nicolau_noiseless.tgz', ... '2010/1komma2mirser_brockhoff_noiseless.tar.gz']) # is the same # doctest:+ELLIPSIS,+SKIP, '...
DONE: join with COCODataArchive, to get there:
- DONE upload definition files to official archives
- DONE? use uploaded definition files (see official_archive_locations in _get_remote
)
- DONE? replace usages of derived data classes by get
- DONE remove definition list in code of the root class
- DONE review and join classes without default for local path
| Static Method | is_archive |
return True if folder contains a COCO archive definition file |
| Method | __init__ |
Argument is a local path to the archive. |
| Method | check_hash |
raise Exception when hashes disagree or file is missing. |
| Method | consistency_check_data |
basic quick consistency check of downloaded data. |
| Method | consistency_check_read |
check/compare against definition file on disk |
| Method | contains |
return True if (the exact) name or path is in the archive |
| Method | full_path |
return full local path of name or any path, idempotent |
| Method | get |
return the full data pathname of substr in the archived data. |
| Method | get_all |
Return a list (StrList ) of absolute pathnames, |
| Method | get_extended |
return a list of valid paths. |
| Method | get_first |
get the first archived data matching all of substrs . |
| Method | get_found |
get full entries of the last find |
| Method | get_one |
deprecated, for backwards compatibility only, use get instead |
| Method | read_definition_file |
return definition triple list |
| Method | update |
update definition file, either from remote location or from local data. |
| Instance Variable | local_data_path |
Undocumented |
| Instance Variable | remote_data_path |
Undocumented |
| Property | downloaded |
return list of data set names of locally available data. |
| Method | _download |
create full local path and download single dataset |
| Method | _hash |
compute hash of name or path |
| Method | _known_hash |
return known hash or None |
| Method | _name |
return supposed name of full_path or name without any checks |
| Method | _name_with_check |
return name of full_path , idempotent. |
| Method | _url_ |
return value of _url_ entry in definition_list file or None . |
| Instance Variable | _all |
Undocumented |
| Instance Variable | _all_dict |
Undocumented |
| Instance Variable | _checked_consistency |
Undocumented |
| Instance Variable | _names_found |
Undocumented |
| Instance Variable | _print |
Undocumented |
| Instance Variable | _redownload_if_changed |
Undocumented |
Inherited from StrList
:
| Method | __call__ |
alias to find |
| Method | find |
return entries that match all substrs . |
| Method | find_indices |
same as find but returns indices instead of names |
| Method | print |
print the result of find(*substrs) with indices. |
| Property | as_string |
return space separated string concatenation surrounded by spaces. |
| Property | found |
StrList of elements found during the last call to find . |
True
if folder
contains a COCO archive definition filecocopp.toolsdivers.StrList.__init__
Argument is a local path to the archive.
This class is not anymore meant to be used directly, rather use
cocopp.archiving.get
.
local_path
is an archive folder containing a definition file,
possibly downloaded with get
calling _get_remote
from a given url
.
~ may refer to the user home folder.
Set _all
and self
from _all
without _url_`
entry.
This init does not deal with remote logic, it only reads in _url_ from
the definition file into the remote_data_path
attribute.
Details: Set _all_dict
which is a (never used) dictionary
generated from _all
and self
and consists of the keys except
for '_url_'.
raise Exception when hashes disagree or file is missing.
raise RunTimeError if hash is unknown raise ValueError if hashes disagree
basic quick consistency check of downloaded data.
return (number_of_checked_data, number_of_all_data)
return the full data pathname of substr
in the archived data.
Retrieves the data from remote if necessary.
substr
can be a substring that matches one and only one name in
the data archive or an integer between 0 and len(self)
, see
find
or cocopp.archiving.OfficialArchives
for how matching is
determined.
Raises a ValueError
if substr
matches several archive entries
on none.
If substr is None (default), the first match of the last
call to find* or get* is used like self.found[0]`
.
If remote is True (default), the respective data are
downloaded from the remote location if necessary. Otherwise
return None
for a match.
Return a list
(StrList
) of absolute pathnames,
by repeatedly calling get
. Elements of the indices
list can
be an index or a substring that matches one and only one name
in the archive. If indices is None, the results from the
last call to find
are used. Download the data if necessary.
See find
or cocopp.archiving.OfficialArchives
for how matching
is determined.
See also get
.
return a list of valid paths.
Elements in args
may be a valid path name or a known name from the
data archive, or a uniquely matching substring of such a name, or a
matching substring with added "!" in which case the first match is taken
only (calling self.get_first
), or a matching substring with added "*"
in which case all matches are taken (calling self.get_all
), or a
regular expression containing a *
and not ending with !
or *
, in
which case, for example, "bbob/2017.*cma" matches
"bbob/2017/DTS-CMA-ES-Pitra.tgz" among others (in a regular expression
"." matches any single character and ".*" matches any number >= 0 of
characters).
get the first archived data matching all of substrs
.
substrs
is a list of substrings.
get_first(substrs, remote)
is a shortcut for:
self.find(*substrs) if self.found: return self.get(self.found[0], remote=remote) return None
update definition file, either from remote location or from local data.
As remote archives may grow or change, a common usecase may be
>>> import cocopp.archiving as ac >>> url = 'https://cma-es.github.io/lq-cma/data-archives/lq-gecco2019' >>> arch = ac.get(url).update() # doctest:+SKIP
For updating a local archive use:
create(self.local_data_path)
Details: for updating the local definition file from the local data
rather use create
. This will however remove a remote URL from its
definition and the remote and the local archive can be different
now. create
makes a backup of the existing definition file.
return list
of data set names of locally available data.
This is only meaningful for a remote archive.
return name of full_path
, idempotent.
If full_path
is not from the data archive a warning is issued
and path seperators are replaced with /
.
Check that all names are only once in the data archive:
>>> import cocopp >>> bbob = cocopp.archives.bbob >>> for name in bbob: ... assert bbob.count(name) == 1, "%s counted %d times in data archive" % (name, bbob.count(name)) ... assert len(bbob.find(name)) == 1, "%s found %d times" % (name, bbob.find(name))


class FileCreateOrUpdateEvent extends ActionEvent
Event fired when a file is created or updated.
Methods
|
__set($name, $value)
|
from ActionEvent | |
|
__get($name)
|
from ActionEvent | |
|
__construct(int $parentId)
Constructor |
||
| $this |
setModel(FileModelInterface $model)
Set file to save |
|
| FileModelInterface |
getModel()
Get file being saved |
|
| $this |
setParentId(int $parentId)
Set Document parent id |
|
| int |
getParentId()
Get Document parent id |
|
| $this |
setUploadedFile(UploadedFile $uploadedFile)
Set uploaded file |
|
| UploadedFile |
getUploadedFile()
Get uploaded file |
|
| $this |
setParentName(string $parentName)
Set parent name |
|
| string |
getParentName()
Get parent name |
|
|
setOldModel(FileModelInterface $oldModel)
Set old model value |
||
| FileModelInterface |
getOldModel()
Get old model value |
Details
in ActionEvent at line 27
public
__set($name, $value)
in ActionEvent at line 32
public
__get($name)
at line 48
public
__construct(int $parentId)
Constructor
at line 60
public $this
setModel(FileModelInterface $model)
Set file to save
at line 72
public FileModelInterface
getModel()
Get file being saved
at line 84
public $this
setParentId(int $parentId)
Set Document parent id
at line 96
public int
getParentId()
Get Document parent id
at line 108
public $this
setUploadedFile(UploadedFile $uploadedFile)
Set uploaded file
at line 120
public UploadedFile
getUploadedFile()
Get uploaded file
at line 132
public $this
setParentName(string $parentName)
Set parent name
at line 144
public string
getParentName()
Get parent name
at line 154
public
setOldModel(FileModelInterface $oldModel)
Set old model value
at line 164
public FileModelInterface
getOldModel()
Get old model value


---
layout: post
title: CFMX - MSDE connection refused error
tags:
- ColdFusion
- MS SQL
status: publish
type: post
published: true
meta:
_edit_last: '2'
---
I just started using MSDE for local development again and after creating my first DSN through the ColdFusion administrator I encountered the following problem:
[code]# Connection verification failed for data source: SMS
java.sql.SQLException: [Macromedia][SQLServer JDBC Driver]Error establishing socket. Connection refused: connect
The root cause was that: java.sql.SQLException: [Macromedia][SQLServer JDBC Driver]Error establishing socket. Connection refused: connect[/code]
First thing I checked (well second after making sure I had provided the right connection details) was to see if anything was listening port on port 1433 by using the handy "netstats -a" command. And there wasn't, so a quick Google search turned up this gem from Robi Sen. Sadly this tool didn't help me as apparently my version didn't need it, but a comment did point me to a another link. But sadly it didn't help me either, but the comment did give me an idea. When I went to check my network set up for MS SQL server, sure enough TCP/IP was not listed... What followed was a moment of banging my head sharply on the table.
Right changes applied, restarted the server, verify connection and...
[code]Connection verification failed for data source: SMS
java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Login failed for user 'hermes'. Reason: Not associated with a trusted SQL Server connection.
The root cause was that: java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Login failed for user 'yourUsername'. Reason: Not associated with a trusted SQL Server connection.[/code]
Well this one only took a few seconds to fix: Windows Authentication only was enabled! Simply open the properties of your server once more, check the security tab and you should see that the option for Windows Authentication is selected. Just change that to SQL server and Windows and you are ready to go...
I guess this is very much a case of damned if you do and damned if you don't for Microsoft as they seemed to have tightened up the security for MS SQL server (I won't even go into the nuisance of trying to install MSDE and being prompted to set an SA password before starting with no indication how to do so), but surely we should be given the option at install time to set these things? Or maybe it's just the MSDE?


practcl - The Practcl Module
The Practcl module is a tool for integrating large modules for C API Tcl code that requires custom Tcl types and TclOO objects.
Generate a proc if no command already exists by that name
A command to do nothing. A handy way of negating an instruction without having to comment it completely out. It's also a handy attachment point for an object to be named later
Drop in a static copy of Tcl
Build a zipfile. On tcl8.6 this invokes the native Zip implementation on older interpreters this invokes zip via exec
Dictionary sort a key/value list. Needed because pre tcl8.6 does not have lsort -stride 2
Detect local platform
Try to load a package, and failing that retrieve tcllib
Read a stylized key/value list stored in a file
Converts a XXX.sh file into a series of Tcl variables
A simpler form of read_sh_file tailored to pulling data from (tcl|tk)Config.sh
A simpler form of read_sh_file tailored to pulling data from a Makefile
Append arguments to a buffer The command works like puts in that each call will also insert a line feed. Unlike puts, blank links in the interstitial are suppressed
grep
Installer tools
Return true if the pkgindex file contains any statement other than "package ifneeded" and/or if any package ifneeded loads a DLL
Index all paths given as though they will end up in the same virtual file system
Ancestor-less class intended to be a mixin which defines a family of build related behaviors that are modified when targetting either gcc or msvc
Class Methods
Methods
find or fake a key/value list describing this project
method DEFS This method populates 4 variables: name - The name of the package version - The version of the package defs - C flags passed to the compiler includedir - A list of paths to feed to the compiler for finding headers
ancestors: practcl::toolset
Methods
Detect what directory contains the Makefile template
Produce a static or dynamic library
Produce a static executable
ancestors: practcl::toolset
Methods
MSVC always builds in the source directory
Do nothing
Detect what directory contains the Makefile template
Dynamic blocks do not generate their own .c files, instead the contribute to the amalgamation of the main library file
Methods
Parser functions
Alias to classic name
Alias to classic name
Module interactions
Practcl internals
Generate code that provides implements Tcl API calls
Generate code that runs when the package/module is initialized into the interpreter
Once an object marks itself as some flavor of dynamic, stop trying to morph it into something else
A deliverable for the build system
Class Methods
Methods
Populate const static data structures
Generate code that provides subroutines called by Tcl API methods
Generate code that provides implements Tcl API calls
This methods generates any Tcl script file which is required to pre-initialize the C library
Methods called by the master project
Methods called by the toolset
ancestors: practcl::product
Flesh out several trivial varieties of product
Methods
ancestors: practcl::dynamic practcl::product
ancestors: practcl::object practcl::product.dynamic
In the end, all C code must be loaded into a module This will either be a dynamically loaded library implementing a tcl extension, or a compiled in segment of a custom shell/app
Methods
Target handling
This methods generates the contents of an amalgamated .c file which implements the loader for a batch of tools
This methods generates the contents of an amalgamated .h file which describes the public API of this module
ancestors: practcl::module
Methods
Exercise the methods of a sub-object
ancestors: practcl::project
Methods
Backward compadible call
Create a "package ifneeded" Args are a list of aliases for which this package will answer to
Standalone class to manage code distribution This class is intended to be mixed into another class (Thus the lack of ancestors)
Class Methods
Methods
ancestors: practcl::distribution
Class Methods
Check for markers in the source root
Check for markers in the metadata
Methods
Clone the source
ancestors: practcl::module
Methods
Install project into the local build system
Methods for packages/tools that can be downloaded possibly built and used internally by this Practcl process Load the facility into the interpreter
Return a file path that exec can call
Install the tool into the local environment
Do whatever is necessary to get the tool into the local environment
Check if tool is available for load/already loaded
ancestors: practcl::subproject practcl::library
A project which the kit compiles and integrates the source for itself
Methods
ancestors: practcl::subproject.binary
ancestors: practcl::subproject.binary
An external library
Methods
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category practcl of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
TclOO
Copyright © 2016-2018 Sean Woods <yoda@etoyoc.com>


?BOTANICAL
GARDE**
Camocladia
platyphyUa
A.
Rich.
Small
seboruco
near
quarry*
limones,
soledad,
cienfuegos.
Collected
for
the
Arnold
Arboretum
by
J.
G.
Jack.
Feb.
24,
19
32.
PLANTS
OF
CUBA
PROVINCE
OF
SANTA
CLARA
No.
8484.
01498919
Legend -
Level of confidence that token is an accurately-transcribed word
extremely low
very low
low
undetermined
medium
high
very high


Generate idealized SWAN boundary forcing function ideal_swan_obc(SwanNodeFile,time,hs,tp,dir,inc,DirectSpread); DESCRIPTION: interpolate Hs,Tp,Dir from WW3 from time series to unstructured SWAN forcing file this is an example file and will need to be modified for specific cases Note that for the unstructured SWAN you can specify separate TPAR files containing time series of hs,tp,dir for each node. Also note that the nodes are not necessarily nodes of the SWAN mesh. They are specified in arclength of the grid units from the first open boundary node (arclength 0). SWAN assembles a boundary segment by piecing together the nodes marked as boundary nodes in the node file (mark = 2). This assumes somehow that the nodes are ordered sequentially along the boundary arc which is in fact a major assumption. Sample OBC section of a swan input file for the GoM domain is as follows where 15 points are used to specify the boundary forcing while the domain in fact has 60 boundary points. SWAN interpolates as necessary to force all the boundary nodes. The large numbers are the arclengths in meters BOUNDSPEC SIDE 2 CLOCKWISE VARIABLE FILE & 0.00 'obc1.bnd' 1 & 52704.26 'obc2.bnd' 1 & 131926.06 'obc3.bnd' 1 & 255117.10 'obc4.bnd' 1 & 390381.71 'obc5.bnd' 1 & 559989.50 'obc6.bnd' 1 & 740759.98 'obc7.bnd' 1 & 924330.66 'obc8.bnd' 1 & 1104489.93 'obc9.bnd' 1 & 1295381.43 'obc10.bnd' 1 & 1480466.74 'obc11.bnd' 1 & 1641071.70 'obc12.bnd' 1 & 1750424.20 'obc13.bnd' 1 & 1828825.67 'obc14.bnd' 1 & 1951072.38 'obc15.bnd' 1
0001 function ideal_swan_obc(SwanNodeFile,time,hs,tp,dir,inc,DirectSpread); 0002 0003 % Generate idealized SWAN boundary forcing 0004 % 0005 % function ideal_swan_obc(SwanNodeFile,time,hs,tp,dir,inc,DirectSpread); 0006 % 0007 % DESCRIPTION: 0008 % interpolate Hs,Tp,Dir from WW3 from time series to unstructured SWAN forcing file 0009 % this is an example file and will need to be modified for specific cases 0010 % Note that for the unstructured SWAN you can specify separate TPAR files 0011 % containing time series of hs,tp,dir for each node. Also note that the nodes 0012 % are not necessarily nodes of the SWAN mesh. They are specified in arclength 0013 % of the grid units from the first open boundary node (arclength 0). SWAN 0014 % assembles a boundary segment by piecing together the nodes marked as boundary 0015 % nodes in the node file (mark = 2). This assumes somehow that the nodes are ordered 0016 % sequentially along the boundary arc which is in fact a major assumption. 0017 % 0018 % Sample OBC section of a swan input file for the GoM domain is as follows where 0019 % 15 points are used to specify the boundary forcing while the domain in fact has 0020 % 60 boundary points. SWAN interpolates as necessary to force all the boundary nodes. 0021 % The large numbers are the arclengths in meters 0022 % 0023 % BOUNDSPEC SIDE 2 CLOCKWISE VARIABLE FILE & 0024 % 0.00 'obc1.bnd' 1 & 0025 % 52704.26 'obc2.bnd' 1 & 0026 % 131926.06 'obc3.bnd' 1 & 0027 % 255117.10 'obc4.bnd' 1 & 0028 % 390381.71 'obc5.bnd' 1 & 0029 % 559989.50 'obc6.bnd' 1 & 0030 % 740759.98 'obc7.bnd' 1 & 0031 % 924330.66 'obc8.bnd' 1 & 0032 % 1104489.93 'obc9.bnd' 1 & 0033 % 1295381.43 'obc10.bnd' 1 & 0034 % 1480466.74 'obc11.bnd' 1 & 0035 % 1641071.70 'obc12.bnd' 1 & 0036 % 1750424.20 'obc13.bnd' 1 & 0037 % 1828825.67 'obc14.bnd' 1 & 0038 % 1951072.38 'obc15.bnd' 1 0039 0040 % INPUT 0041 % SwanNodeFile: Swan node file (e.g. tst.node) 0042 % time: time stamp of time series in modified Julian day 0043 % hs: time series for significant wave height 0044 % tp: time series for peak period 0045 % dir: time series for wave direction 0046 % inc: dump TPAR obc forcing file every inc boundary points 0047 % DirectSpread directional spreading of incoming waves in degrees 0048 % 0049 % OUTPUT: 0050 % SWAN open boundary TPAR files obcXX.bnd 0051 % cntrllist.txt: list of open boundary arclengths and obc file names 0052 % this can essentially be pasted into the swan input file 0053 % 0054 % Author(s): 0055 % Geoff Cowles (University of Massachusetts Dartmouth) 0056 % 0057 % Revision history 0058 % 0059 %============================================================================== 0060 0061 0062 % read the swan node file and grab boundary nodes 0063 [num,x,y,mark] = textread(SwanNodeFile,'%d %f %f %d\n','headerlines',1); 0064 obc_nodes = find(mark==2); 0065 nobc = prod(size(obc_nodes)); 0066 xtmp = x(obc_nodes); 0067 ytmp = y(obc_nodes); 0068 arc = zeros(nobc,1); 0069 for i=2:nobc 0070 arc(i) = arc(i-1) + sqrt( (xtmp(i)-xtmp(i-1))^2 + (ytmp(i)-ytmp(i-1))^2); 0071 end; 0072 0073 % shift to discrete locations 0074 pts = 1:inc:nobc; 0075 pts(end) = nobc; 0076 xobc = xtmp(pts); 0077 yobc = ytmp(pts); 0078 aobc = arc(pts); 0079 nTPAR = prod(size(xobc)); 0080 0081 0082 %--------------------------------------------------------- 0083 % set TPAR files for each open boundary forcing point 0084 %--------------------------------------------------------- 0085 0086 0087 % preallocate arrays 0088 nTimes = prod(size(time)); 0089 0090 %dump to separate swan forcing files 0091 for i=1:nTPAR 0092 fname = ['obc' num2str(i) '.bnd']; 0093 fid = fopen(fname,'w'); 0094 fid = fprintf(fid,'TPAR\n'); 0095 for j=1:nTimes 0096 [year,month,day,hour,mint,sec] = mjulian2greg(time(j)); 0097 if(day < 10) 0098 daystr = ['0' int2str(day)]; 0099 else 0100 daystr = int2str(day); 0101 end; 0102 if(month < 10) 0103 monthstr = ['0' int2str(month)]; 0104 else 0105 monthstr = int2str(month); 0106 end; 0107 if(hour < 10) 0108 hourstr = ['0' int2str(hour)]; 0109 else 0110 hourstr = int2str(hour); 0111 end; 0112 date = [' ' int2str(year) monthstr daystr '.' hourstr '00']; 0113 fprintf(fid,'%s %f %f %f %f\n',date,hs(j),tp(j),dir(j),DirectSpread); 0114 end; 0115 fclose(fid); 0116 end; 0117 0118 % dump the main swan control file list 0119 fname = 'cntrllist.txt'; 0120 fid = fopen(fname,'w'); 0121 for i=1:nTPAR 0122 fname = [' ''obc' num2str(i) '.bnd'' ']; 0123 fprintf(fid,'%12.2f %s %d %s\n',aobc(i),fname,1,'&'); 0124 end; 0125