pax_global_header 0000666 0000000 0000000 00000000064 12556443544 0014526 g ustar 00root root 0000000 0000000 52 comment=28317091f99b8faba3aac17fa7c1ec258fb002de
fnordmetric-0.1.0.20150502+gite736fba3/ 0000775 0000000 0000000 00000000000 12556443544 0016655 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/.gitignore 0000664 0000000 0000000 00000000012 12556443544 0020636 0 ustar 00root root 0000000 0000000 .DS_Store
fnordmetric-0.1.0.20150502+gite736fba3/.travis.yml 0000664 0000000 0000000 00000000116 12556443544 0020764 0 ustar 00root root 0000000 0000000 rvm: 1.9.3
script: ./fnordmetric-core/run_specs.sh
services:
- redis-server
fnordmetric-0.1.0.20150502+gite736fba3/Dockerfile 0000664 0000000 0000000 00000001375 12556443544 0020655 0 ustar 00root root 0000000 0000000 FROM ubuntu:14.04
RUN apt-get update \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*
RUN buildDeps='unzip git gcc make clang++-3.4 cmake libmysqlclient-dev'; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/src/ \
&& cd /usr/src \
&& curl -R -O https://codeload.github.com/dolfly/fnordmetric/zip/master \
&& unzip master \
&& cd fnordmetric-master/fnordmetric-core \
&& make \
&& cp build/cmake/target/fnordmetric-server /usr/local/bin
VOLUME /data/fnordmetric
EXPOSE 8080 8125/udp
CMD [ "/usr/local/bin/fnordmetric-server", "--http_port", "8080", "--statsd_port", "8125", "--storage_backend", "disk", "--datadir", "/data/fnordmetric"]
fnordmetric-0.1.0.20150502+gite736fba3/LICENSE 0000664 0000000 0000000 00000104513 12556443544 0017666 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
fnordmetric-0.1.0.20150502+gite736fba3/Makefile 0000664 0000000 0000000 00000001153 12556443544 0020315 0 ustar 00root root 0000000 0000000 # This file is part of the "FnordMetric" project
# Copyright (c) 2014 Paul Asmuth, Google Inc.
#
# Licensed under the MIT license (see LICENSE).
all: build
build:
(cd fnordmetric-webui && make build)
(cd fnordmetric-core && make build)
install:
(cd fnordmetric-core && make install)
test:
(cd fnordmetric-core && make test)
clean:
(cd fnordmetric-webui && make clean)
(cd fnordmetric-core && make clean)
doc:
find doc/examples -name "*.sql" | while read file; do PATH=./build:$$PATH fnordmetric -f svg -o $${file/.sql/.svg}.html $$file; done
(cd doc/web && rake build)
.PHONY: all test clean doc build
fnordmetric-0.1.0.20150502+gite736fba3/README.md 0000664 0000000 0000000 00000007602 12556443544 0020141 0 ustar 00root root 0000000 0000000 FnordMetric
===========
FnordMetric allows you collect and visualize timeseries data using only SQL. It
enables you to build beautiful real-time analytics dashboards within minutes.
Documentation: [fnordmetric.io](http://fnordmetric.io/)
Demo Video: [http://fnordmetric.io/fnordmetric-server.mp4](http://fnordmetric.io/fnordmetric-server.mp4)
[  ](http://github.com/paulasmuth/fnordmetric)
#### FnordMetric ChartSQL
FnordMetric ChartSQL allows you to write SQL queries that return charts instead
of tables. The charts are rendered as SVG vector graphics and can easily be
embedded into any website and customized with css in order to build beautiful
dashboards.
You can execute ChartSQL queries from the command line against a number of
external sources like CSV files or a MySQL database.
#### FnordMetric Server
Fnordmetric Server is a standalone HTTP server application. It exposes a web UI
and a HTTP API to run ChartSQL queries and collect timeseries data. You can use
fnordmetric-server as a one-stop solution for metric collection and charting.
Since fnordmetric-server aims to be a StatsD+graphite competitor, it implements
a wire compatible StatsD API.
FnordMetric Server can store the collected timeseries data on local disk or in
external storage (HBase).
Documentation
-------------
You can find the full FnordMetric Documentation at http://fnordmetric.io/
Contributions
-------------
#### Individual Contributors to FnordMetric
+ Laura Schlimmer (http://github.com/lauraschlimmer)
+ Henrik Muehe (http://github.com/henrik-muehe)
+ Philipp Bogensberger (http://github.com/bogensberger)
+ "Dolfly" (http://github.com/dolfly)
+ Christian Parpart (http://github.com/trapni)
+ Finn Zirngibl (https://github.com/finnomenon)
+ Simon Menke (http://github.com/fd)
+ Bruno Michel (http://github.com/nono)
+ Marco Borromeo (http://github.com/mborromeo)
+ Leo Lou (http://github.com/l4u)
+ Andy Lindeman (http://github.com/alindeman)
+ Jurriaan Pruis (http://github.com/jurriaan)
+ Kacper Bielecki (http://github.com/kazjote)
+ John Murray (http://github.com/JohnMurray)
+ Lars Gierth (http://github.com/lgierth)
+ Ross Kaffenberger (http://github.com/rossta)
+ Kunal Modi (http://github.com/kunalmodi)
+ Michael Fairchild (http://github.com/fairchild)
+ James Cox (http://github.com/imajes)
+ Pieter Noordhuis (http://github.com/pietern)
+ Tadas Ščerbinskas (http://github.com/tadassce)
+ Sebastian Korfmann (http://github.com/skorfmann)
+ Paul Asmuth (http://github.com/paulasmuth)
To contribute, please fork this repository, make your changes and run the
specs, commit them to your github repository and send me a pull request.
Need help, head on over to our [Google Groups][1] page to discuss any ideas
that you might have.
#### Other Open Source Software included in FnordMetric
+ Marijn Haverbeke's CodeMirror --- javascript code editor (https://github.com/marijnh/codemirror)
+ FontAwesome --- icon font (http://fontawesome.io/)
License
-------
Copyright (c) 2011-2014 Paul Asmuth
FnordMetric is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
FnordMetric is distributed in the hope that it will be useful,but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
FnordMetric. If not, see .
[1]: http://groups.google.com/group/fnordmetric
[2]: http://www.screenr.com/KiJs
[3]: https://secure.travis-ci.org/paulasmuth/fnordmetric.png
[4]: http://travis-ci.org/paulasmuth/fnordmetric
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-agents/ 0000775 0000000 0000000 00000000000 12556443544 0022450 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-agents/linux-agent/ 0000775 0000000 0000000 00000000000 12556443544 0024703 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-agents/linux-agent/fm-linux-agent.rb 0000664 0000000 0000000 00000011032 12556443544 0030060 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require "timeout"
require "socket"
###############################################################################
# Prefix every metric name with this string
METRIC_NAME_PREFIX = "/linux/"
# Report the statistics every 1 second
INTERVAL = 1.0
###############################################################################
if ARGV.length != 2
puts "usage: #{$0} "
puts " Report Linux system stats to FnordMetric Server via statsd"
puts ""
puts "example: #{$0} 127.0.0.1 8125"
exit 1
end
udp = UDPSocket.new
target_host = ARGV[0]
target_port = ARGV[1].to_i
loop do
last_run = Time.now.to_f
@samples = []
# hostname
@hostname = `hostname`.strip
# collect CPU load averages
def report_cpu_load
if File.exists?("/proc/loadavg")
loadavg_data = IO::read("/proc/loadavg")
loadavg = loadavg_data.scan(/([0-9]+[,\.][0-9]+)+/).flatten
if loadavg.size == 3
@samples << {
:metric => "load_avg_1m",
:value => loadavg[0],
:labels => {
:host => @hostname
}
}
@samples << {
:metric => "load_avg_5m",
:value => loadavg[1],
:labels => {
:host => @hostname
}
}
@samples << {
:metric => "load_avg_15m",
:value => loadavg[2],
:labels => {
:host => @hostname
}
}
end
end
end
# gather basic memory statistics
def report_memory_stats
if File.exists?("/proc/meminfo")
loadavg_data = IO::read("/proc/meminfo")
memtotal = loadavg_data.scan(/MemTotal:\s+ (\d+)\skB/).flatten.first.to_i
memfree = loadavg_data.scan(/MemFree:\s+ (\d+)\skB/).flatten.first.to_i
swaptotal = loadavg_data.scan(/SwapTotal:\s+ (\d+)\skB/).flatten.first.to_i
swapfree = loadavg_data.scan(/SwapFree:\s+ (\d+)\skB/).flatten.first.to_i
@samples << {
:metric => "memory_total",
:value => memtotal,
:labels => {
:host => @hostname
}
}
@samples << {
:metric => "memory_free",
:value => memfree,
:labels => {
:host => @hostname
}
}
@samples << {
:metric => "swap_total",
:value => swaptotal,
:labels => {
:host => @hostname
}
}
@samples << {
:metric => "swap_free",
:value => swapfree,
:labels => {
:host => @hostname
}
}
end
end
# determine disk usage and available space
def report_disk_stats
df_input = `df -P`.lines[1..-1]
if !df_input.empty?
df_input.each do |single_line|
elements = single_line.split " "
@samples << {
:metric => "disk_used",
:value => elements[2],
:labels => {
:host => @hostname,
:mount_name => elements[0]
}
}
@samples << {
:metric => "disk_available",
:value => elements[3],
:labels => {
:host => @hostname,
:mount_name => elements[0]
}
}
end
end
end
#count open TCP and UDP sockets
def report_open_sockets
if File.exists?("/proc/net/tcp")
tcp_sockets = %x{wc -l "/proc/net/tcp"}.to_i - 1
@samples << {
:metric => "open_tcp_sockets",
:value => tcp_sockets,
:labels => {
:host => @hostname
}
}
end
if File.exists?("/proc/net/udp")
tcp_sockets = %x{wc -l "/proc/net/udp"}.to_i - 1
@samples << {
:metric => "open_udp_sockets",
:value => tcp_sockets,
:labels => {
:host => @hostname
}
}
end
end
# fill samples array with data
report_memory_stats
report_disk_stats
report_cpu_load
report_open_sockets
# send the samples in a single udp packet to FnordMetric server (the combined
# packet size must be strictly less than or equal to 65535 bytes
packet = ""
@samples.each do |sample|
packet << METRIC_NAME_PREFIX + sample[:metric]
sample[:labels].each do |k,v|
packet << "[#{k}=#{v}]"
end
packet << ":"
packet << sample[:value].to_s.gsub(",", ".")
packet << "\n"
end
begin
udp.send packet, 0, target_host, target_port
rescue Exception => e
puts e
end
# sleep if we completed executing faster than the requested interval
sleep_for = (last_run + INTERVAL) - Time.now.to_f
sleep(sleep_for) if sleep_for > 0
end
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-agents/osx-agent/ 0000775 0000000 0000000 00000000000 12556443544 0024355 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-agents/osx-agent/fm-osx-agent.rb 0000775 0000000 0000000 00000003577 12556443544 0027226 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require "timeout"
require "socket"
###############################################################################
# Prefix every metric name with this string
METRIC_NAME_PREFIX = "/osx/"
# Report the statistics every 1 second
INTERVAL = 1.0
###############################################################################
if ARGV.length != 2
puts "usage: #{$0} "
puts " Report OSX system stats to FnordMetric Server via statsd"
puts ""
puts "example: #{$0} 127.0.0.1 8125"
exit 1
end
udp = UDPSocket.new
target_host = ARGV[0]
target_port = ARGV[1].to_i
loop do
last_run = Time.now.to_f
samples = []
# hostname
hostname = `hostname`.strip
# uptime
uptime = `uptime`.strip
# gather load averages
if uptime =~ /load averages?: ([0-9]+[,\.][0-9]+)\s+([0-9]+[,\.][0-9]+)\s+([0-9]+[,\.][0-9]+)/
samples << {
:metric => "load_avg_1m",
:value => $1,
:labels => {
:host => hostname
}
}
samples << {
:metric => "load_avg_5m",
:value => $2,
:labels => {
:host => hostname
}
}
samples << {
:metric => "load_avg_15m",
:value => $3,
:labels => {
:host => hostname
}
}
end
# send the samples in a single udp packet to FnordMetric server (the combined
# packet size must be strictly less than or equal to 65535 bytes
packet = ""
samples.each do |sample|
packet << METRIC_NAME_PREFIX + sample[:metric]
sample[:labels].each do |k,v|
packet << "[#{k}=#{v}]"
end
packet << ":"
packet << sample[:value].to_s.gsub(",", ".")
packet << "\n"
end
begin
udp.send packet, 0, target_host, target_port
rescue Exception => e
puts e
end
# sleep if we completed executing faster than the requested interval
sleep_for = (last_run + INTERVAL) - Time.now.to_f
sleep(sleep_for) if sleep_for > 0
end
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/ 0000775 0000000 0000000 00000000000 12556443544 0022117 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/Makefile 0000664 0000000 0000000 00000001074 12556443544 0023561 0 ustar 00root root 0000000 0000000 # This file is part of the "FnordMetric" project
# Copyright (c) 2014 Paul Asmuth, Google Inc.
#
# Licensed under the MIT license (see LICENSE).
all: build
build:
(cd ../fnordmetric-webui && make)
(cd build/cmake && make)
install: build
(cd build/cmake && make install)
devserver: build
mkdir -p /tmp/fnordmetric-data
DEV_ASSET_PATH=../ ./build/cmake/target/fnordmetric-server --datadir /tmp/fnordmetric-data --verbose
test:
(cd build/cmake && make test)
clean:
(cd build/cmake && make clean)
rm -rf build/test/tmp*
.PHONY: all test clean build devserver
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/autogen.sh 0000775 0000000 0000000 00000000116 12556443544 0024116 0 ustar 00root root 0000000 0000000 #!/bin/bash
if [[ "$1" == "clean" ]]; then
make clean
exit 0
fi
make all
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/ 0000775 0000000 0000000 00000000000 12556443544 0023216 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/.gitignore 0000664 0000000 0000000 00000000113 12556443544 0025201 0 ustar 00root root 0000000 0000000 fnordmetric
libfnordmetric-static.a
libfnordmetric.dylib
libfnordmetric.so
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/ 0000775 0000000 0000000 00000000000 12556443544 0024276 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/.gitignore 0000664 0000000 0000000 00000000015 12556443544 0026262 0 ustar 00root root 0000000 0000000 stage
target
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/CMakeLists.txt 0000664 0000000 0000000 00000025130 12556443544 0027037 0 ustar 00root root 0000000 0000000 # This file is part of the "FnordMetric" project
# Copyright (c) 2014 Paul Asmuth, Google Inc.
#
# FnordMetric is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License v3.0. You should have received a
# copy of the GNU General Public License along with this program. If not, see
# .
cmake_minimum_required(VERSION 2.6)
include(FindPkgConfig)
include(CheckIncludeFile)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/")
project(fnordmetric)
option(ENABLE_TESTS "Build unit tests [default: off]" OFF)
set(FNORDMETRIC_SOURCES
stage/src/fnordmetric/cli/cli.cc
stage/src/fnordmetric/cli/flagparser.cc
stage/src/fnordmetric/cli/cli.cc
stage/src/fnordmetric/io/acceptor.cc
stage/src/fnordmetric/io/eventloop.cc
stage/src/fnordmetric/io/file.cc
stage/src/fnordmetric/io/fileutil.cc
stage/src/fnordmetric/io/filerepository.cc
stage/src/fnordmetric/io/mmappedfile.cc
stage/src/fnordmetric/io/pagemanager.cc
stage/src/fnordmetric/net/udpserver.cc
stage/src/fnordmetric/environment.cc
stage/src/fnordmetric/http/httpinputstream.cc
stage/src/fnordmetric/http/httpoutputstream.cc
stage/src/fnordmetric/http/httpmessage.cc
stage/src/fnordmetric/http/httprequest.cc
stage/src/fnordmetric/http/httpresponse.cc
stage/src/fnordmetric/http/httpserver.cc
stage/src/fnordmetric/sstable/cursor.cc
stage/src/fnordmetric/sstable/fileheaderreader.cc
stage/src/fnordmetric/sstable/fileheaderwriter.cc
stage/src/fnordmetric/sstable/index.cc
stage/src/fnordmetric/sstable/indexprovider.cc
stage/src/fnordmetric/sstable/rowoffsetindex.cc
stage/src/fnordmetric/sstable/sstablereader.cc
stage/src/fnordmetric/sstable/sstablerepair.cc
stage/src/fnordmetric/sstable/sstablewriter.cc
stage/src/fnordmetric/util/assets.cc
stage/src/fnordmetric/util/binarymessagereader.cc
stage/src/fnordmetric/util/binarymessagewriter.cc
stage/src/fnordmetric/util/buffer.cc
stage/src/fnordmetric/util/datetime.cc
stage/src/fnordmetric/util/exceptionhandler.cc
stage/src/fnordmetric/util/format.cc
stage/src/fnordmetric/util/fnv.cc
stage/src/fnordmetric/util/ieee754.cc
stage/src/fnordmetric/util/inputstream.cc
stage/src/fnordmetric/util/inspect.cc
stage/src/fnordmetric/util/logger.cc
stage/src/fnordmetric/util/logoutputstream.cc
stage/src/fnordmetric/util/outputstream.cc
stage/src/fnordmetric/util/jsonoutputstream.cc
stage/src/fnordmetric/util/random.cc
stage/src/fnordmetric/util/runtimeexception.cc
stage/src/fnordmetric/util/signalhandler.cc
stage/src/fnordmetric/util/stringutil.cc
stage/src/fnordmetric/util/uri.cc
stage/src/fnordmetric/util/wallclock.cc
stage/src/fnordmetric/ui/axisdefinition.cc
stage/src/fnordmetric/ui/areachart.cc
stage/src/fnordmetric/ui/barchart.cc
stage/src/fnordmetric/ui/linechart.cc
stage/src/fnordmetric/ui/pointchart.cc
stage/src/fnordmetric/ui/canvas.cc
stage/src/fnordmetric/ui/domain.cc
stage/src/fnordmetric/ui/domainprovider.cc
stage/src/fnordmetric/ui/drawable.cc
stage/src/fnordmetric/ui/griddefinition.cc
stage/src/fnordmetric/ui/legenddefinition.cc
stage/src/fnordmetric/ui/series.cc
stage/src/fnordmetric/ui/timedomain.cc
stage/src/fnordmetric/sql/backends/csv/csvbackend.cc
stage/src/fnordmetric/sql/backends/csv/csvinputstream.cc
stage/src/fnordmetric/sql/backends/csv/csvtableref.cc
stage/src/fnordmetric/sql/backends/mysql/mysqlbackend.cc
stage/src/fnordmetric/sql/backends/mysql/mysqlconnection.cc
stage/src/fnordmetric/sql/backends/mysql/mysqltableref.cc
stage/src/fnordmetric/sql/backends/postgres/postgresbackend.cc
stage/src/fnordmetric/sql/backends/postgres/postgresconnection.cc
stage/src/fnordmetric/sql/backends/postgres/postgrestableref.cc
stage/src/fnordmetric/query/query.cc
stage/src/fnordmetric/query/queryservice.cc
stage/src/fnordmetric/sql/expressions/aggregate.cc
stage/src/fnordmetric/sql/expressions/boolean.cc
stage/src/fnordmetric/sql/expressions/datetime.cc
stage/src/fnordmetric/sql/expressions/math.cc
stage/src/fnordmetric/sql/parser/astnode.cc
stage/src/fnordmetric/sql/parser/astutil.cc
stage/src/fnordmetric/sql/parser/parser.cc
stage/src/fnordmetric/sql/parser/token.cc
stage/src/fnordmetric/sql/parser/tokenize.cc
stage/src/fnordmetric/sql/runtime/compile.cc
stage/src/fnordmetric/sql/runtime/defaultruntime.cc
stage/src/fnordmetric/sql/runtime/execute.cc
stage/src/fnordmetric/sql/runtime/groupovertimewindow.cc
stage/src/fnordmetric/sql/runtime/orderby.cc
stage/src/fnordmetric/sql/runtime/importstatement.cc
stage/src/fnordmetric/sql/runtime/queryplan.cc
stage/src/fnordmetric/sql/runtime/queryplanbuilder.cc
stage/src/fnordmetric/sql/runtime/queryplannode.cc
stage/src/fnordmetric/sql/runtime/runtime.cc
stage/src/fnordmetric/sql/runtime/symboltable.cc
stage/src/fnordmetric/sql/runtime/tablerepository.cc
stage/src/fnordmetric/sql/runtime/tablescan.cc
stage/src/fnordmetric/sql/svalue.cc
stage/src/fnordmetric/sql_extensions/areachartbuilder.cc
stage/src/fnordmetric/sql_extensions/barchartbuilder.cc
stage/src/fnordmetric/sql_extensions/linechartbuilder.cc
stage/src/fnordmetric/sql_extensions/pointchartbuilder.cc
stage/src/fnordmetric/sql_extensions/domainconfig.cc
stage/src/fnordmetric/sql_extensions/drawstatement.cc
stage/src/fnordmetric/sql_extensions/seriesadapter.cc
stage/src/fnordmetric/thread/threadpool.cc
stage/src/fnordmetric/metricdb/adminui.cc
stage/src/fnordmetric/metricdb/backends/disk/compactiontask.cc
stage/src/fnordmetric/metricdb/backends/disk/metric.cc
stage/src/fnordmetric/metricdb/backends/disk/metriccursor.cc
stage/src/fnordmetric/metricdb/backends/disk/metricsnapshot.cc
stage/src/fnordmetric/metricdb/backends/disk/metricrepository.cc
stage/src/fnordmetric/metricdb/backends/disk/labelindex.cc
stage/src/fnordmetric/metricdb/backends/disk/labelindexreader.cc
stage/src/fnordmetric/metricdb/backends/disk/labelindexwriter.cc
stage/src/fnordmetric/metricdb/backends/disk/samplereader.cc
stage/src/fnordmetric/metricdb/backends/disk/samplewriter.cc
stage/src/fnordmetric/metricdb/backends/disk/tableheaderreader.cc
stage/src/fnordmetric/metricdb/backends/disk/tableheaderwriter.cc
stage/src/fnordmetric/metricdb/backends/disk/tableref.cc
stage/src/fnordmetric/metricdb/backends/disk/tokenindex.cc
stage/src/fnordmetric/metricdb/backends/disk/tokenindexreader.cc
stage/src/fnordmetric/metricdb/backends/disk/tokenindexwriter.cc
stage/src/fnordmetric/metricdb/backends/inmemory/metric.cc
stage/src/fnordmetric/metricdb/backends/inmemory/metricrepository.cc
stage/src/fnordmetric/metricdb/httpapi.cc
stage/src/fnordmetric/metricdb/metric.cc
stage/src/fnordmetric/metricdb/metricrepository.cc
stage/src/fnordmetric/metricdb/metrictableref.cc
stage/src/fnordmetric/metricdb/metrictablerepository.cc
stage/src/fnordmetric/metricdb/sample.cc
stage/src/fnordmetric/metricdb/statsd.cc)
include_directories(${PROJECT_BINARY_DIR})
include_directories(stage/src)
include_directories(stage/assets)
if(APPLE)
set(CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
endif()
add_executable(fnordmetric-cli ${FNORDMETRIC_SOURCES} stage/src/fnordmetric/cli.cc)
target_link_libraries(fnordmetric-cli m)
install(TARGETS fnordmetric-cli DESTINATION bin)
add_executable(fnordmetric-server ${FNORDMETRIC_SOURCES} stage/src/fnordmetric/server.cc)
target_link_libraries(fnordmetric-server m)
install(TARGETS fnordmetric-server DESTINATION bin)
find_package(Threads)
target_link_libraries(fnordmetric-cli ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(fnordmetric-server ${CMAKE_THREAD_LIBS_INIT})
find_package(MySQL)
if(MYSQL_FOUND)
set(FNORD_ENABLE_MYSQL true)
target_link_libraries(fnordmetric-cli ${MYSQL_CLIENT_LIBS})
target_link_libraries(fnordmetric-server ${MYSQL_CLIENT_LIBS})
else()
message("WARNING: libmysqlclient not found, FnordMetric will be compiled without MySQL support")
endif()
find_package(PostgreSQL)
if(PostgreSQL_FOUND)
set(FNORD_ENABLE_POSTGRES true)
target_link_libraries(fnordmetric-cli ${PostgreSQL_LIBRARIES})
target_link_libraries(fnordmetric-server ${PostgreSQL_LIBRARIES})
else()
message("WARNING: libpq not found, FnordMetric will be compiled without Postgres support")
endif()
configure_file(config.h.in config.h)
if(ENABLE_TESTS)
add_library(fnord SHARED ${FNORDMETRIC_SOURCES})
target_link_libraries(fnord m ${MYSQL_CLIENT_LIBS})
add_executable(tests/test-sql stage/src/fnordmetric/sql/sql_test.cc)
target_link_libraries(tests/test-sql fnord)
add_executable(tests/test-ui
stage/src/fnordmetric/ui/ui_test.cc)
target_link_libraries(tests/test-ui fnord)
add_executable(tests/test-input-stream
stage/src/fnordmetric/util/inputstream_test.cc)
target_link_libraries(tests/test-input-stream fnord)
add_executable(tests/test-uri
stage/src/fnordmetric/util/uri_test.cc)
target_link_libraries(tests/test-uri fnord)
add_executable(tests/test-http
stage/src/fnordmetric/http/http_test.cc)
target_link_libraries(tests/test-http fnord)
target_link_libraries(tests/test-uri fnord)
add_executable(tests/test-fnv
stage/src/fnordmetric/util/fnv_test.cc)
target_link_libraries(tests/test-fnv fnord)
add_executable(tests/test-csv-backend
stage/src/fnordmetric/sql/backends/csv/csvbackend_test.cc)
target_link_libraries(tests/test-csv-backend fnord)
add_executable(tests/test-pagemanager
stage/src/fnordmetric/io/pagemanager_test.cc)
target_link_libraries(tests/test-pagemanager fnord)
add_executable(tests/test-sstable
stage/src/fnordmetric/sstable/sstable_test.cc)
target_link_libraries(tests/test-sstable fnord)
add_executable(tests/test-sql-extensions
stage/src/fnordmetric/sql_extensions/sql_extensions_test.cc)
target_link_libraries(tests/test-sql-extensions fnord)
add_executable(tests/test-query
stage/src/fnordmetric/query/query_test.cc)
target_link_libraries(tests/test-query fnord)
add_executable(tests/test-cli stage/src/fnordmetric/cli/cli_test.cc)
target_link_libraries(tests/test-cli fnord)
add_executable(tests/test-statsd
stage/src/fnordmetric/metricdb/statsd_test.cc)
target_link_libraries(tests/test-statsd fnord)
add_executable(tests/test-disk-backend
stage/src/fnordmetric/metricdb/backends/disk/diskbackend_test.cc)
target_link_libraries(tests/test-disk-backend fnord)
endif()
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/Makefile 0000664 0000000 0000000 00000001375 12556443544 0025744 0 ustar 00root root 0000000 0000000 # This file is part of the "FnordMetric" project
# Copyright (c) 2014 Paul Asmuth, Google Inc.
#
# Licensed under the MIT license (see LICENSE).
all: assets
mkdir -p target/tests
mkdir -p stage/src
test -e stage/src/fnordmetric || ln -s ../../../../src stage/src/fnordmetric || true
(cd target && cmake .. -DCMAKE_BUILD_TYPE=Release && make)
rm -f ../fnordmetric
rm -f ../libfnordmetric-static.a
rm -f ../libfnordmetric.dylib
rm -f ../libfnordmetric.so
ln -s cmake/target/fnordmetric ../fnordmetric
install:
(cd target && cmake .. && make install)
assets:
./assets.sh
test: all
@find target/tests -iname "test-*" | while read t; do (cd ../../ && build/cmake/$$t) || exit 1; done
clean:
rm -rf target stage
.PHONY: all test clean assets install
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/assets.sh 0000775 0000000 0000000 00000003333 12556443544 0026141 0 ustar 00root root 0000000 0000000 #/bin/bash
set -e
mkdir -p stage/src
echo "#include " > stage/src/asset_bundle.cc
asset_file() {
(cd ../../.. && cat $@ | xxd -i)
echo "};"
}
asset_uniq() {
echo "static const unsigned char __$1_data[] = {"
}
asset_name() {
echo "static fnordmetric::util::Assets::AssetFile __$1(\"$2\", __$1_data, sizeof(__$1_data));"
};
(
asset_uniq "fnordmetric_js_fnordmetric_js"
asset_file "fnordmetric-js/fnordmetric.js"
asset_name "fnordmetric_js_fnordmetric_js" "fnordmetric-js/fnordmetric.js"
) >> stage/src/asset_bundle.cc
(
asset_uniq "fnordmetric_webui_fnordmetric_webui_css"
asset_file "fnordmetric-webui/fnordmetric-webui.css"
asset_name "fnordmetric_webui_fnordmetric_webui_css" "fnordmetric-webui/fnordmetric-webui.css"
) >> stage/src/asset_bundle.cc
(
asset_uniq "fnordmetric_webui_fnordmetric_webui_html"
asset_file "fnordmetric-webui/fnordmetric-webui.html"
asset_name "fnordmetric_webui_fnordmetric_webui_html" "fnordmetric-webui/fnordmetric-webui.html"
) >> stage/src/asset_bundle.cc
(
asset_uniq "fnordmetric_webui_fnordmetric_webui_js"
asset_file "fnordmetric-webui/fnordmetric-webui.js"
asset_name "fnordmetric_webui_fnordmetric_webui_js" "fnordmetric-webui/fnordmetric-webui.js"
) >> stage/src/asset_bundle.cc
(
asset_uniq "fnordmetric_webui_fnordmetric_favicon_ico"
asset_file "fnordmetric-webui/fnordmetric-favicon.ico"
asset_name "fnordmetric_webui_fnordmetric_favicon_ico" "fnordmetric-webui/fnordmetric-favicon.ico"
) >> stage/src/asset_bundle.cc
(
asset_uniq "fnordmetric_webui_fontawesome_woff"
asset_file "fnordmetric-webui/fontawesome.woff"
asset_name "fnordmetric_webui_fontawesome_woff" "fnordmetric-webui/fontawesome.woff"
) >> stage/src/asset_bundle.cc
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/config.h.in 0000664 0000000 0000000 00000000103 12556443544 0026313 0 ustar 00root root 0000000 0000000 #cmakedefine FNORD_ENABLE_MYSQL
#cmakedefine FNORD_ENABLE_POSTGRES
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules/ 0000775 0000000 0000000 00000000000 12556443544 0025746 5 ustar 00root root 0000000 0000000 CMakeParseArguments.cmake 0000664 0000000 0000000 00000013454 12556443544 0032541 0 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules #.rst:
# CMakeParseArguments
# -------------------
#
#
#
# CMAKE_PARSE_ARGUMENTS(
# args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
# for parsing the arguments given to that macro or function. It
# processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any
# value following, like e.g. the OPTIONAL keyword of the install()
# command.
#
# The argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The argument contains all keywords for this
# macro which can be followed by more than one value, like e.g. the
# TARGETS or FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in , and
# a variable composed of the given
# followed by "_" and the name of the respective keyword. These
# variables will then hold the respective value from the argument list.
# For the keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# _UNPARSED_ARGUMENTS, this can be checked afterwards to see
# whether your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments
# as the real install() command:
#
# ::
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}"
# "${multiValueArgs}" ${ARGN} )
# ...
#
#
#
# Assume my_install() has been called like this:
#
# ::
#
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
#
#
# After the cmake_parse_arguments() call the macro will have set the
# following variables:
#
# ::
#
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
#
#
# You can then continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a
# one_value_keyword another recognized keyword follows, this is
# interpreted as the beginning of the new option. E.g.
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach()
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else()
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif()
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach()
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction()
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules/FindMySQL.cmake 0000664 0000000 0000000 00000007674 12556443544 0030534 0 ustar 00root root 0000000 0000000 #--------------------------------------------------------
# Copyright (C) 1995-2007 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# There are special exceptions to the terms and conditions of the GPL
# as it is applied to this software. View the full text of the exception
# in file LICENSE.exceptions in the top-level directory of this software
# distribution.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# The MySQL Connector/ODBC is licensed under the terms of the
# GPL, like most MySQL Connectors. There are special exceptions
# to the terms and conditions of the GPL as it is applied to
# this software, see the FLOSS License Exception available on
# mysql.com.
##########################################################################
#-------------- FIND MYSQL_INCLUDE_DIR ------------------
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
/usr/include/mysql
/usr/local/include/mysql
/opt/mysql/mysql/include
/opt/mysql/mysql/include/mysql
/opt/mysql/include
/opt/local/include/mysql5
/usr/local/mysql/include
/usr/local/mysql/include/mysql
$ENV{ProgramFiles}/MySQL/*/include
$ENV{SystemDrive}/MySQL/*/include)
#----------------- FIND MYSQL_LIB_DIR -------------------
IF (WIN32)
# Set lib path suffixes
# dist = for mysql binary distributions
# build = for custom built tree
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
SET(libsuffixDist debug)
SET(libsuffixBuild Debug)
ELSE (CMAKE_BUILD_TYPE STREQUAL Debug)
SET(libsuffixDist opt)
SET(libsuffixBuild Release)
ADD_DEFINITIONS(-DDBUG_OFF)
ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug)
FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient
PATHS
$ENV{MYSQL_DIR}/lib/${libsuffixDist}
$ENV{MYSQL_DIR}/libmysql
$ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
$ENV{MYSQL_DIR}/client/${libsuffixBuild}
$ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
$ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist}
$ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist})
ELSE (WIN32)
FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient_r
PATHS
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/local/mysql5/lib
/opt/local/lib/mysql5/mysql
/opt/mysql/mysql/lib/mysql
/opt/mysql/lib/mysql)
ENDIF (WIN32)
IF(MYSQL_LIB)
GET_FILENAME_COMPONENT(MYSQL_LIB_DIR ${MYSQL_LIB} PATH)
ENDIF(MYSQL_LIB)
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
SET(MYSQL_FOUND TRUE)
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
LINK_DIRECTORIES(${MYSQL_LIB_DIR})
FIND_LIBRARY(MYSQL_ZLIB zlib PATHS ${MYSQL_LIB_DIR})
FIND_LIBRARY(MYSQL_YASSL yassl PATHS ${MYSQL_LIB_DIR})
FIND_LIBRARY(MYSQL_TAOCRYPT taocrypt PATHS ${MYSQL_LIB_DIR})
SET(MYSQL_CLIENT_LIBS mysqlclient_r)
IF (MYSQL_ZLIB)
SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} zlib)
ENDIF (MYSQL_ZLIB)
IF (MYSQL_YASSL)
SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} yassl)
ENDIF (MYSQL_YASSL)
IF (MYSQL_TAOCRYPT)
SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} taocrypt)
ENDIF (MYSQL_TAOCRYPT)
# Added needed mysqlclient dependencies on Windows
IF (WIN32)
SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} ws2_32)
ENDIF (WIN32)
MESSAGE(STATUS "MySQL Include dir: ${MYSQL_INCLUDE_DIR} library dir: ${MYSQL_LIB_DIR}")
MESSAGE(STATUS "MySQL client libraries: ${MYSQL_CLIENT_LIBS}")
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
FindPackageHandleStandardArgs.cmake 0000664 0000000 0000000 00000034742 12556443544 0034451 0 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules #.rst:
# FindPackageHandleStandardArgs
# -----------------------------
#
#
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... )
#
# This function is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED, QUIET and version-related arguments to
# find_package(). It also sets the _FOUND variable. The
# package is considered found if all variables ... listed contain
# valid results, e.g. valid filepaths.
#
# There are two modes of this function. The first argument in both
# modes is the name of the Find-module where it is called (in original
# casing).
#
# The first simple mode looks like this:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(
# (DEFAULT_MSG|"Custom failure message") ... )
#
# If the variables to are all valid, then
# _FOUND will be set to TRUE. If DEFAULT_MSG is given
# as second argument, then the function will generate itself useful
# success and error messages. You can also supply a custom error
# message for the failure case. This is not recommended.
#
# The second mode is more powerful and also supports version checking:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(
# [FOUND_VAR ]
# [REQUIRED_VARS ...]
# [VERSION_VAR ]
# [HANDLE_COMPONENTS]
# [CONFIG_MODE]
# [FAIL_MESSAGE "Custom failure message"] )
#
# In this mode, the name of the result-variable can be set either to
# either _FOUND or _FOUND using the
# FOUND_VAR option. Other names for the result-variable are not
# allowed. So for a Find-module named FindFooBar.cmake, the two
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
# to use the original case version. If the FOUND_VAR option is not
# used, the default is _FOUND.
#
# As in the simple mode, if through are all valid,
# _FOUND will be set to TRUE. After REQUIRED_VARS the
# variables which are required for this package are listed. Following
# VERSION_VAR the name of the variable can be specified which holds the
# version of the package which has been found. If this is done, this
# version will be checked against the (potentially) specified required
# version used in the find_package() call. The EXACT keyword is also
# handled. The default messages include information about the required
# version and the version which has been actually found, both if the
# version is ok or not. If the package supports components, use the
# HANDLE_COMPONENTS option to enable handling them. In this case,
# find_package_handle_standard_args() will report which components have
# been found and which are missing, and the _FOUND variable
# will be set to FALSE if any of the required components (i.e. not the
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
# set to _VERSION and the macro will automatically check whether
# the Config module was found. Via FAIL_MESSAGE a custom failure
# message can be specified, if this is not used, the default message
# will be displayed.
#
# Example for mode 1:
#
# ::
#
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG
# LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
#
#
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
# TRUE. If it is not found and REQUIRED was used, it fails with
# FATAL_ERROR, independent whether QUIET was used or not. If it is
# found, success will be reported, including the content of . On
# repeated Cmake runs, the same message won't be printed again.
#
# Example for mode 2:
#
# ::
#
# find_package_handle_standard_args(LibXslt
# FOUND_VAR LibXslt_FOUND
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
# VERSION_VAR LibXslt_VERSION_STRING)
#
# In this case, LibXslt is considered to be found if the variable(s)
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
# LibXslt_FOUND . Also the version of LibXslt will be checked by using
# the version contained in LibXslt_VERSION_STRING. Since no
# FAIL_MESSAGE is given, the default messages will be printed.
#
# Another example for mode 2:
#
# ::
#
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
#
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
# NO_MODULE) and adds an additional search directory for automoc4. Here
# the result will be stored in AUTOMOC4_FOUND. The following
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
# success/error message.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
# internal helper macro
macro(_FPHSA_FAILURE_MESSAGE _msg)
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${_msg}")
else ()
if (NOT ${_NAME}_FIND_QUIETLY)
message(STATUS "${_msg}")
endif ()
endif ()
endmacro()
# internal helper macro to generate the failure message when used in CONFIG_MODE:
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
# _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
if(${_NAME}_CONFIG)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
else()
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
# List them all in the error message:
if(${_NAME}_CONSIDERED_CONFIGS)
set(configsText "")
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
math(EXPR configsCount "${configsCount} - 1")
foreach(currentConfigIndex RANGE ${configsCount})
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
set(configsText "${configsText} ${filename} (version ${version})\n")
endforeach()
if (${_NAME}_NOT_FOUND_MESSAGE)
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
endif()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
else()
# Simple case: No Config-file was found at all:
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
endif()
endif()
endmacro()
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
# new extended or in the "old" mode:
set(options CONFIG_MODE HANDLE_COMPONENTS)
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
set(multiValueArgs REQUIRED_VARS)
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
if(${INDEX} EQUAL -1)
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
set(FPHSA_REQUIRED_VARS ${ARGN})
set(FPHSA_VERSION_VAR)
else()
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
if(FPHSA_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT FPHSA_FAIL_MESSAGE)
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
endif()
endif()
# now that we collected all arguments, process them
if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
endif()
# In config-mode, we rely on the variable _CONFIG, which is set by find_package()
# when it successfully found the config-file, including version checking:
if(FPHSA_CONFIG_MODE)
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
endif()
if(NOT FPHSA_REQUIRED_VARS)
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
endif()
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
string(TOUPPER ${_NAME} _NAME_UPPER)
string(TOLOWER ${_NAME} _NAME_LOWER)
if(FPHSA_FOUND_VAR)
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
else()
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
endif()
else()
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
endif()
# collect all variables which were not found, so they can be printed, so the
# user knows better what went wrong (#6375)
set(MISSING_VARS "")
set(DETAILS "")
# check if all passed variables are valid
unset(${_FOUND_VAR})
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
if(NOT ${_CURRENT_VAR})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
else()
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
endif()
endforeach()
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
set(${_FOUND_VAR} TRUE)
endif()
# component handling
unset(FOUND_COMPONENTS_MSG)
unset(MISSING_COMPONENTS_MSG)
if(FPHSA_HANDLE_COMPONENTS)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(${_NAME}_${comp}_FOUND)
if(NOT DEFINED FOUND_COMPONENTS_MSG)
set(FOUND_COMPONENTS_MSG "found components: ")
endif()
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
else()
if(NOT DEFINED MISSING_COMPONENTS_MSG)
set(MISSING_COMPONENTS_MSG "missing components: ")
endif()
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${comp}")
endif()
endif()
endforeach()
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
endif()
# version handling:
set(VERSION_MSG "")
set(VERSION_OK TRUE)
set(VERSION ${${FPHSA_VERSION_VAR}})
# check with DEFINED here as the requested or found version may be "0"
if (DEFINED ${_NAME}_FIND_VERSION)
if(DEFINED ${FPHSA_VERSION_VAR})
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
# count the dots in the version string
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}")
# add one dot because there is one dot more than there are components
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
# Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT
# is at most 4 here. Therefore a simple lookup table is used.
if (${_NAME}_FIND_VERSION_COUNT EQUAL 1)
set(_VERSION_REGEX "[^.]*")
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2)
set(_VERSION_REGEX "[^.]*\\.[^.]*")
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3)
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*")
else ()
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
endif ()
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}")
unset(_VERSION_REGEX)
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
endif ()
unset(_VERSION_HEAD)
else ()
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION)
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
endif ()
endif ()
unset(_VERSION_DOTS)
else() # minimum version specified:
if (${_NAME}_FIND_VERSION VERSION_GREATER VERSION)
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
endif ()
endif()
else()
# if the package was not found, but a version was given, add that to the output:
if(${_NAME}_FIND_VERSION_EXACT)
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
else()
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
endif()
endif()
else ()
if(VERSION)
set(VERSION_MSG "(found version \"${VERSION}\")")
endif()
endif ()
if(VERSION_OK)
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
else()
set(${_FOUND_VAR} FALSE)
endif()
# print the result:
if (${_FOUND_VAR})
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
else ()
if(FPHSA_CONFIG_MODE)
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
else()
if(NOT VERSION_OK)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
else()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
endif()
endif()
endif ()
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
endfunction()
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules/FindPackageMessage.cmake0000664 0000000 0000000 00000003755 12556443544 0032423 0 ustar 00root root 0000000 0000000 #.rst:
# FindPackageMessage
# ------------------
#
#
#
# FIND_PACKAGE_MESSAGE( "message for user" "find result details")
#
# This macro is intended to be used in FindXXX.cmake modules files. It
# will print a message once for each unique find result. This is useful
# for telling the user where a package was found. The first argument
# specifies the name (XXX) of the package. The second argument
# specifies the message to display. The third argument lists details
# about the find result so that if they change the message will be
# displayed again. The macro also obeys the QUIET argument to the
# find_package command.
#
# Example:
#
# ::
#
# if(X11_FOUND)
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
# else()
# ...
# endif()
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
function(FIND_PACKAGE_MESSAGE pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
string(REPLACE "\n" "" details "${details}")
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
# The message has not yet been printed.
message(STATUS "${msg}")
# Save the find details in the cache to avoid printing the same
# message again.
set("${DETAILS_VAR}" "${details}"
CACHE INTERNAL "Details about finding ${pkg}")
endif()
endif()
endfunction()
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/cmake/modules/FindPostgreSQL.cmake 0000664 0000000 0000000 00000017263 12556443544 0031565 0 ustar 00root root 0000000 0000000 #.rst:
# FindPostgreSQL
# --------------
#
# Find the PostgreSQL installation.
#
# In Windows, we make the assumption that, if the PostgreSQL files are
# installed, the default directory will be C:\Program Files\PostgreSQL.
#
# This module defines
#
# ::
#
# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
#=============================================================================
# Copyright 2004-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# ----------------------------------------------------------------------------
# History:
# This module is derived from the module originally found in the VTK source tree.
#
# ----------------------------------------------------------------------------
# Note:
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
# version mumber of the implementation of PostgreSQL.
# In Windows the default installation of PostgreSQL uses that as part of the path.
# E.g C:\Program Files\PostgreSQL\8.4.
# Currently, the following version numbers are known to this module:
# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
#
# To use this variable just do something like this:
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
# This will mean that the versions you set here will be found first in the order
# specified before the default ones are searched.
#
# ----------------------------------------------------------------------------
# You may need to manually set:
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
# If FindPostgreSQL.cmake cannot find the include files or the library files.
#
# ----------------------------------------------------------------------------
# The following variables are set if PostgreSQL is found:
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
#
# ----------------------------------------------------------------------------
# If you have installed PostgreSQL in a non-standard location.
# (Please note that in the following comments, it is assumed that
# points to the root directory of the include directory of PostgreSQL.)
# Then you have three options.
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to /include and
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
# 2) Use CMAKE_INCLUDE_PATH to set a path to /PostgreSQL<-version>. This will allow find_path()
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include")
# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
# installed PostgreSQL, e.g. .
#
# ----------------------------------------------------------------------------
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
"9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
# Define additional search paths for root directories.
if ( WIN32 )
foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} )
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" )
endforeach()
endif()
set( PostgreSQL_ROOT_DIRECTORIES
ENV PostgreSQL_ROOT
${PostgreSQL_ROOT}
${PostgreSQL_ADDITIONAL_SEARCH_PATHS}
)
#
# Look for an installation.
#
find_path(PostgreSQL_INCLUDE_DIR
NAMES libpq-fe.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
pgsql
postgresql
include
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
find_path(PostgreSQL_TYPE_INCLUDE_DIR
NAMES catalog/pg_type.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
postgresql
pgsql/server
postgresql/server
include/server
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
# The PostgreSQL library.
set (PostgreSQL_LIBRARY_TO_FIND pq)
# Setting some more prefixes for the library
set (PostgreSQL_LIB_PREFIX "")
if ( WIN32 )
set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
endif()
find_library( PostgreSQL_LIBRARY
NAMES ${PostgreSQL_LIBRARY_TO_FIND}
PATHS
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
lib
)
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
if (PostgreSQL_INCLUDE_DIR)
# Some platforms include multiple pg_config.hs for multi-lib configurations
# This is a temporary workaround. A better solution would be to compile
# a dummy c file and extract the value of the symbol.
file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
if(pgsql_version_str)
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
unset(pgsql_version_str)
endif()
# Did we find anything?
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(PostgreSQL
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
VERSION_VAR PostgreSQL_VERSION_STRING)
set( PostgreSQL_FOUND ${POSTGRESQL_FOUND})
# Now try to get the include and library path.
if(PostgreSQL_FOUND)
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
#message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
#message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
#message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
endif()
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY ) fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/tests/ 0000775 0000000 0000000 00000000000 12556443544 0024360 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/build/tests/.gitignore 0000664 0000000 0000000 00000000004 12556443544 0026342 0 ustar 00root root 0000000 0000000 tmp
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ 0000775 0000000 0000000 00000000000 12556443544 0022706 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli.cc 0000664 0000000 0000000 00000002343 12556443544 0023766 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace fnordmetric;
static const char kCrashErrorMsg[] =
"FnordMetric crashed :( -- Please report a bug at "
"github.com/paulasmuth/fnordmetric";
int main(int argc, const char** argv) {
/* setup environment */
fnord::util::CatchAndAbortExceptionHandler ehandler(kCrashErrorMsg);
ehandler.installGlobalHandlers();
util::SignalHandler::ignoreSIGHUP();
util::SignalHandler::ignoreSIGPIPE();
fnord::util::Random::init();
/* execute commandline */
cli::CLI::parseArgs(env(), argc, argv);
cli::CLI::executeSafely(env());
return 0;
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/ 0000775 0000000 0000000 00000000000 12556443544 0023455 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/cli.cc 0000664 0000000 0000000 00000012554 12556443544 0024542 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace fnordmetric {
namespace cli {
void CLI::parseArgs(Environment* env, const std::vector& argv) {
auto flags = env->flags();
// Execute queries from the commandline:
flags->defineFlag(
"format",
FlagParser::T_STRING,
false,
"f",
"table",
"The output format { svg, csv, table }",
"");
flags->defineFlag(
"output",
FlagParser::T_STRING,
false,
"o",
NULL,
"Write output to a file",
"");
flags->defineFlag(
"verbose",
FlagParser::T_SWITCH,
false,
NULL,
NULL,
"Be verbose");
flags->defineFlag(
"help",
FlagParser::T_SWITCH,
false,
"h",
NULL,
"You are reading it...");
flags->parseArgv(argv);
env->setVerbose(flags->isSet("verbose"));
}
void CLI::parseArgs(Environment* env, int argc, const char** argv) {
std::vector args;
for (int i = 1; i < argc; ++i) {
args.emplace_back(argv[i]);
}
parseArgs(env, args);
}
void CLI::printUsage() {
auto err_stream = fnordmetric::util::OutputStream::getStderr();
err_stream->printf("usage: fnordmetric-cli [options] [file.sql]\n");
err_stream->printf("\noptions:\n");
env()->flags()->printUsage(err_stream.get());
err_stream->printf("\nexamples:\n");
err_stream->printf(" $ fnordmeric-cli -f svg -o out.svg myquery.sql\n");
err_stream->printf(" $ fnordmeric-cli -f svg - < myquery.sql > out.svg\n");
}
int CLI::executeSafely(Environment* env) {
auto err_stream = util::OutputStream::getStderr();
try {
if (env->flags()->isSet("help")) {
printUsage();
return 0;
}
execute(env);
} catch (const util::RuntimeException& e) {
if (e.getTypeName() == "UsageError") {
err_stream->printf("\n");
printUsage();
return 1;
}
if (env->verbose()) {
env->logger()->exception("FATAL", "Fatal error", e);
} else {
auto msg = e.getMessage();
err_stream->printf("[ERROR] ");
err_stream->write(msg.c_str(), msg.size());
err_stream->printf("\n");
}
return 1;
}
return 0;
}
void CLI::execute(Environment* env) {
auto flags = env->flags();
const auto& args = flags->getArgv();
/* open input stream */
std::shared_ptr input;
if (args.size() == 1) {
if (args[0] == "-") {
if (env->verbose()) {
env->logger()->log("DEBUG", "Input from stdin");
}
input = std::move(util::InputStream::getStdin());
} else {
if (env->verbose()) {
env->logger()->log("DEBUG", "Input file: " + args[0]);
}
input = std::move(util::FileInputStream::openFile(args[0]));
}
} else {
RAISE("UsageError", "usage error");
}
/* open output stream */
std::shared_ptr output;
if (flags->isSet("output")) {
auto output_file = flags->getString("output");
if (env->verbose()) {
env->logger()->log("DEBUG", "Output file: " + output_file);
}
output = std::move(util::FileOutputStream::openFile(output_file));
} else {
if (env->verbose()) {
env->logger()->log("DEBUG", "Output to stdout");
}
output = std::move(util::OutputStream::getStdout());
}
/* execute query */
query::QueryService query_service;
query_service.registerBackend(
std::unique_ptr(
new fnordmetric::query::mysql_backend::MySQLBackend));
query_service.registerBackend(
std::unique_ptr(
new fnordmetric::query::postgres_backend::PostgresBackend));
query_service.registerBackend(
std::unique_ptr(
new fnordmetric::query::csv_backend::CSVBackend));
query_service.executeQuery(
input,
getOutputFormat(env),
output);
}
const query::QueryService::kFormat CLI::getOutputFormat(Environment* env) {
auto flags = env->flags();
if (!flags->isSet("format")) {
return query::QueryService::FORMAT_TABLE;
}
auto format_str = flags->getString("format");
if (format_str == "csv") {
return query::QueryService::FORMAT_CSV;
}
if (format_str == "json") {
return query::QueryService::FORMAT_JSON;
}
if (format_str == "svg") {
return query::QueryService::FORMAT_SVG;
}
if (format_str == "table") {
return query::QueryService::FORMAT_TABLE;
}
RAISE(
kRuntimeError,
"invalid format: '%s', allowed formats are "
"'svg', 'csv', 'json' and 'table'",
format_str.c_str());
}
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/cli.h 0000664 0000000 0000000 00000002262 12556443544 0024377 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_CLI_H
#define _FNORDMETRIC_CLI_H
#include
#include
#include
namespace fnordmetric {
class Environment;
namespace cli {
class FlagParser;
class CLI {
public:
/**
* Parse a command line
*/
static void parseArgs(Environment* env, const std::vector& argv);
static void parseArgs(Environment* env, int argc, const char** argv);
/**
* Execute a command line but do not throw exceptions
*/
static int executeSafely(Environment* env);
/**
* Execute a command line
*/
static void execute(Environment* env);
protected:
static void printUsage();
static const query::QueryService::kFormat getOutputFormat(Environment* env);
};
}
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/cli_test.cc 0000664 0000000 0000000 00000002427 12556443544 0025577 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace fnordmetric::cli;
UNIT_TEST(CLITest);
static fnordmetric::util::UnitTest::TestCase __test_simple_sql_to_svg_(
&CLITest, "TestSimpleSQLToSVG", [] () {
fnord::io::FileUtil::mkdir_p("build/tests/tmp");
std::vector args = {
"test/fixtures/gdp_bar_chart.sql",
"-f", "svg",
"-o", "build/tests/tmp/CLITest_TestSimpleSQLToSVG_out.svg.html"
};
fnordmetric::Environment myenv;
CLI::parseArgs(&myenv, args);
CLI::execute(&myenv);
EXPECT_FILES_EQ(
"test/fixtures/CLITest_TestSimpleSQLToSVG_out.svg.html",
"build/tests/tmp/CLITest_TestSimpleSQLToSVG_out.svg.html");
});
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/flagparser.cc 0000664 0000000 0000000 00000012704 12556443544 0026116 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
namespace fnordmetric {
namespace cli {
FlagParser::FlagParser() {}
void FlagParser::defineFlag(
const char* longopt,
kFlagType type,
bool required,
const char* shortopt /* = NULL */,
const char* default_value /* = NULL */,
const char* description /* = NULL */,
const char* placeholder /* = NULL */) {
FlagState flag_state;
flag_state.type = type;
flag_state.required = required;
flag_state.longopt = longopt;
flag_state.shortopt = shortopt;
flag_state.default_value = default_value;
flag_state.description = description;
flag_state.placeholder = placeholder;
flags_.emplace_back(flag_state);
}
bool FlagParser::isSet(const char* longopt) const {
for (auto& flag : flags_) {
if (flag.longopt == longopt) {
return flag.default_value != nullptr || flag.values.size() > 0;
}
}
return false;
}
std::string FlagParser::getString(const char* longopt) const {
for (auto& flag : flags_) {
if (flag.longopt == longopt) {
if (flag.type != T_STRING) {
RAISE(kFlagError, "flag '%s' is not a string", longopt);
}
if (flag.values.size() == 0) {
if (flag.default_value != nullptr) {
return flag.default_value;
}
RAISE(kFlagError, "flag '%s' is not set", longopt);
}
return flag.values.back();
}
}
RAISE(kFlagError, "flag '%s' is not set", longopt);
}
int64_t FlagParser::getInt(const char* longopt) const {
for (auto& flag : flags_) {
if (flag.longopt == longopt) {
if (flag.type != T_INTEGER) {
RAISE(kFlagError, "flag '%s' is not an integer", longopt);
}
std::string flag_value_str;
if (flag.values.size() == 0) {
if (flag.default_value != nullptr) {
flag_value_str = flag.default_value;
} else {
RAISE(kFlagError, "flag '%s' is not set", longopt);
}
} else {
flag_value_str = flag.values.back();
}
int64_t flag_value;
try {
flag_value = std::stoi(flag_value_str);
} catch (std::exception e) {
RAISE(
kFlagError,
"flag '%s' value '%s' is not a valid integer",
longopt,
flag.values.back().c_str());
}
return flag_value;
}
}
RAISE(kFlagError, "flag '%s' is not set", longopt);
}
void FlagParser::parseArgv(int argc, const char** argv) {
std::vector args;
for (int i = 1; i < argc; ++i) {
args.emplace_back(argv[i]);
}
parseArgv(args);
}
// FIXPAUL optimize with hashmap?
void FlagParser::parseArgv(const std::vector& argv) {
for (int i = 0; i < argv.size(); i++) {
int eq_len = -1;
FlagState* flag_ptr = nullptr;
auto& arg = argv[i];
if (arg.size() == 0) {
continue;
}
for (auto& flag : flags_) {
auto longopt = std::string("--") + flag.longopt;
auto longopt_eq = std::string("--") + flag.longopt + "=";
if (arg.compare(0, longopt.size(), longopt) == 0) {
flag_ptr = &flag;
}
else if (arg.compare(0, longopt_eq.size(), longopt_eq) == 0) {
flag_ptr = &flag;
eq_len = longopt_eq.size();
}
else if (flag.shortopt != nullptr) {
auto shortopt = std::string("-") + flag.shortopt;
auto shortopt_eq = std::string("-") + flag.shortopt + "=";
if (arg.compare(0, shortopt.size(), shortopt) == 0) {
flag_ptr = &flag;
}
else if (arg.compare(0, shortopt_eq.size(), shortopt_eq) == 0) {
flag_ptr = &flag;
eq_len = shortopt_eq.size();
}
}
if (flag_ptr != nullptr) {
break;
}
}
if (flag_ptr == nullptr) {
argv_.push_back(arg);
} else if (flag_ptr->type == T_SWITCH) {
flag_ptr->values.emplace_back("true");
} else if (eq_len > 0) {
if (arg.size() == eq_len) {
RAISE(kFlagError, "flag --%s=... has no value", flag_ptr->longopt);
}
flag_ptr->values.emplace_back(arg.substr(eq_len));
} else {
if (i + 1 >= argv.size()) {
RAISE(kFlagError, "flag --%s has no value", flag_ptr->longopt);
}
flag_ptr->values.emplace_back(argv[++i]);
}
}
for (const auto& flag : flags_) {
if (flag.required == true && flag.values.size() == 0) {
RAISE(kFlagError, "flag --%s is required", flag.longopt);
}
}
}
const std::vector& FlagParser::getArgv() const {
return argv_;
}
void FlagParser::printUsage(util::OutputStream* target) const {
for (const auto& flag : flags_) {
if (flag.shortopt == nullptr) {
target->printf(" --%-26.26s", flag.longopt);
} else {
target->printf(" -%s, --%-12.12s", flag.shortopt, flag.longopt);
}
const char* placeholder = nullptr;
if (flag.placeholder == nullptr) {
switch (flag.type) {
case T_STRING:
placeholder = "";
break;
case T_INTEGER:
placeholder = "";
break;
case T_FLOAT:
placeholder = "";
break;
case T_SWITCH:
placeholder = "";
break;
}
} else {
placeholder = flag.placeholder;
}
target->printf("%-12.12s", placeholder);
if (flag.description != nullptr) {
target->printf("%s\n", flag.description);
} else {
target->printf("\n");
}
}
}
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/cli/flagparser.h 0000664 0000000 0000000 00000004510 12556443544 0025754 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_FLAGPARSER_H
#define _FNORDMETRIC_FLAGPARSER_H
#include
#include
#include
namespace fnordmetric {
namespace util {
class OutputStream;
}
namespace cli {
const char kFlagError[] = "FlagError";
class FlagParser {
public:
enum kFlagType {
T_SWITCH,
T_STRING,
T_FLOAT,
T_INTEGER
};
FlagParser();
/**
* Define a flag
*/
void defineFlag(
const char* longopt,
kFlagType type,
bool required,
const char* shortopt = NULL,
const char* default_value = NULL,
const char* description = NULL,
const char* placeholder = NULL);
/**
* Returns true if the flag is set and false otherwise
*
* @param longopt the longopt of the flag
*/
bool isSet(const char* longopt) const;
/**
* Returns the string value of the flag or throws an exception if the value
* is invalid.
*
* @param longopt the longopt of the flag
*/
std::string getString(const char* longopt) const;
/**
* Returns the integer value of the flag or throws an exception if the value
* is invalid.
*
* @param longopt the longopt of the flag
*/
int64_t getInt(const char* longopt) const;
/**
* Parse an argv array. This may throw an exception.
*/
void parseArgv(int argc, const char** argv);
/**
* Parse an argv array. This may throw an exception.
*/
void parseArgv(const std::vector& argv);
/**
* Get the argv array with all flag args removed
*/
const std::vector& getArgv() const;
void printUsage(util::OutputStream* target) const;
protected:
struct FlagState {
kFlagType type;
bool required;
const char* longopt;
const char* shortopt;
const char* default_value;
const char* description;
const char* placeholder;
std::vector values;
};
std::vector argv_;
std::vector flags_;
};
}
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/environment.cc 0000664 0000000 0000000 00000001436 12556443544 0025565 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
using fnord::util::LogOutputStream;
namespace fnordmetric {
Environment* env() {
static Environment global_env;
return &global_env;
}
Environment::Environment() :
logger_(new LogOutputStream(util::OutputStream::getStderr())) {}
void Environment::setVerbose(bool verbose) {
verbose_ = verbose;
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/environment.h 0000664 0000000 0000000 00000001762 12556443544 0025431 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_ENVIRONMENT_H
#define _FNORDMETRIC_ENVIRONMENT_H
#include
#include
#include
#include "config.h"
using fnord::util::Logger;
namespace fnordmetric {
class Environment {
public:
Environment();
inline cli::FlagParser* flags() {
return &flag_parser_;
}
inline Logger* logger() {
return logger_.get();
}
inline bool verbose() {
return verbose_;
}
void setVerbose(bool verbose);
protected:
bool verbose_;
cli::FlagParser flag_parser_;
std::unique_ptr logger_;
};
Environment* env();
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/ 0000775 0000000 0000000 00000000000 12556443544 0023464 5 ustar 00root root 0000000 0000000 fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/agent.cc 0000664 0000000 0000000 00000001461 12556443544 0025073 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include "agent.h"
#include "query/query.h"
namespace fnordmetric {
std::unique_ptr Agent::executeQuery(
const std::string& query_string) const {
std::unique_ptr query(new query::Query(query_string, *this));
return query;
}
std::shared_ptr Agent::findStreamByName(
const std::string& stream_name) const {
//return std::shared_ptr(nullptr);
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/agent.h 0000664 0000000 0000000 00000002721 12556443544 0024735 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordStream" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* Licensed under the MIT license (see LICENSE).
*/
#ifndef _FNORDMETRIC_AGENT_H
#define _FNORDMETRIC_AGENT_H
#include
#include
#include
#include "stream.h"
#include "database/database.h"
namespace fnordmetric {
namespace query {
class QueryTest;
}
/**
* Agent
*/
class Agent : public IStreamRepository {
friend class query::QueryTest;
public:
explicit Agent(
const std::string& name,
std::unique_ptr&& database);
Agent(const Agent& copy) = delete;
Agent& operator=(const Agent& copy) = delete;
Agent(Agent&& move);
/**
* Open a stream for writing data
*/
template
std::shared_ptr> openStream(
const std::string& name,
//const StreamDescription& description,
const T... fields);
/**
* Execute a query
*/
std::unique_ptr executeQuery
(const std::string& query_string) const;
/**
* Find a stream by name if a stream with that name exists. Otherwise return
* std::shared_ptr(nullptr)
*/
virtual std::shared_ptr findStreamByName(
const std::string& stream_name) const;
protected:
std::string name_;
std::vector> streams_;
std::mutex streams_mutex_;
std::unique_ptr database_;
};
}
#include "agent_impl.h"
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/agent_impl.h 0000664 0000000 0000000 00000001704 12556443544 0025756 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordStream" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* Licensed under the MIT license (see LICENSE).
*/
#ifndef _FNORDMETRIC_AGENT_IMPL_H
#define _FNORDMETRIC_AGENT_IMPL_H
namespace fnordmetric {
Agent::Agent(
const std::string& name,
std::unique_ptr&& database) :
name_(name),
database_(std::move(database)) {}
template
std::shared_ptr> Agent::openStream(
const std::string& name,
//const StreamDescription& description,
const T... fields) {
TypedSchema schema(fields...);
TypedStreamKey key(name, fields...);
streams_mutex_.lock();
auto stream_ref = database_->openStream(key.getKeyString());
auto stream = std::make_shared>(
key,
schema,
std::move(stream_ref));
streams_.push_back(stream);
streams_mutex_.unlock();
return stream;
}
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/aocollection.cc 0000664 0000000 0000000 00000007625 12556443544 0026460 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
#include
#include
#include "aocollection.h"
#include "pagemanager.h"
#include "transaction.h"
#include "cursor.h"
#include "documentref.h"
namespace fnordmetric {
//size_t Database::kMaxPageSizeSoft = 4194304;
//size_t Database::kMaxPageSizeHard = 33554432;
uint64_t AOCollection::kInitialIndexPageSize = 65535;
AOCollection::AOCollection(
const Schema& schema,
std::shared_ptr page_manager,
std::unique_ptr seq) :
Collection(schema, page_manager),
page_index_(std::shared_ptr(new PageIndex(page_manager))),
seq_(std::move(seq)),
last_key_(0) {}
AOCollection::~AOCollection() {
sync();
}
std::unique_ptr AOCollection::getSnapshot() {
auto snapshot = new AOCollection::Snapshot();
return std::unique_ptr(snapshot);
}
bool AOCollection::commitTransaction(const Transaction* transaction) {
commit_mutex_.lock();
auto index = page_index_->clone();
bool rollback = false;
for (auto docref : transaction->getDirtyDocuments()) {
if (docref->isDirty()) {
auto key = docref->getDocumentKey();
if (!key.isIntKey()) {
printf("error: unsupported key type\n"); // FIXPAUL
goto rollback_tx;
}
if (key.getIntKey() == 0) {
uint64_t next_key = seq_->getNext(last_key_);
docref->setDocumentKey(DocumentKey(next_key));
last_key_ = next_key;
} else if (key.getIntKey() <= last_key_) {
printf("error: keys must be monotonically increasing\n"); // FIXPAUL
goto rollback_tx;
}
appendDocument(docref, index);
}
}
commit_tx:
printf("commit!");
page_index_mutex_.lock();
page_index_ = std::shared_ptr(index);
page_index_mutex_.unlock();
commit_mutex_.unlock();
return true;
rollback_tx:
// FIXPAUL if error free the index copy!
commit_mutex_.unlock();
return false;
}
void AOCollection::appendDocument(
const DocumentRef* docref,
PageIndex* index) {
char* data;
size_t size;
/* get document body */
docref->getScratchpad(&data, &size);
size_t envelope_size = size + sizeof(DocHeader);
assert(size > 0);
/* get document key */
uint64_t key = docref->getDocumentKey().getIntKey();
assert(key > 0);
/* retrieve the page for inserting */
auto index_ref = index->getIndexPageEntryForInsert(envelope_size);
PageManager::Page page(index_ref->offset, index_ref->size);
auto page_ref = page_manager_->getPage(page);
/* copy metadata into document header */
DocHeader* document = page_ref->structAt(index_ref->used);
document->key = key;
document->size = size;
/* copy document body and compute checksum*/
memcpy(document->data, data, size);
//row->checksum = row->computeChecksum();
if (index_ref->first_key == 0) {
index_ref->first_key = key;
}
index_ref->used += envelope_size;
}
void AOCollection::sync() {
sync_mutex_.lock();
// capture free page list
auto index = getPageIndex();
page_manager_->fsync();
//writeRootPage(index_page);
// release freed pages
sync_mutex_.unlock();
}
std::shared_ptr AOCollection::getPageIndex() const {
page_index_mutex_.lock();
auto index = page_index_;
page_index_mutex_.unlock();
return index;
}
std::unique_ptr AOCollection::Snapshot::getCursor(
const DocumentKey& key) {
assert(0);
}
//Document* AOCollection::Transaction::getDocument(
// const fnordmetric::Cursor* cursor) {
//}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/aocollection.h 0000664 0000000 0000000 00000011007 12556443544 0026307 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_FILEBACKEND_FILEBACKEND_H
#define _FNORDMETRIC_FILEBACKEND_FILEBACKEND_H
#include
#include
#include
#include
#include
#include "pagemanager.h"
#include "collection.h"
#include "cursor.h"
#include "transaction.h"
#include "pageindex.h"
/**
*
* eBNF:
*
*
FILE ::= FILE_HEADER
*( PAGE )
FILE_HEADER ::= <8 Bytes 0x17> ; magic bytes
; version number
PAGE_PTR ; pointer to first log page
PAGE ::= ( LOG_PAGE | DATA_PAGE )
PAGE_PTR ::= ; page offset in the file in bytes
; size of the page in bytes
LOG_PAGE ::= *( LOG_ENTRY )
LOG_ENTRY ::= ( LOG_ENTRY_NEXT | LOG_ENTRY_ALLOC | LOG_ENTRY_FREE )
LOG_ENTRY_NEXT ::= LOG_ENTRY_CHECKSUM
LOG_ENTRY_TYPE ; 0x01
LOG_ENTRY_LENGTH ; 0x08
PAGE_PTR ; pointer to next log page
LOG_ENTRY_ALLOC ::= LOG_ENTRY_CHECKSUM
LOG_ENTRY_TYPE ; 0x02
LOG_ENTRY_LENGTH ; variable
PAGE_PTR ; pointer to the data page
UNIX_MILLIS ; timestamp of the page's first row
STREAM_ID
[ STREAM_KEY ] ; length = LOG_ENTRY_LENGTH - 16
LOG_ENTRY_FREE ::= LOG_ENTRY_CHECKSUM
LOG_ENTRY_TYPE ; 0x03
LOG_ENTRY_LENGTH ; 0x10
PAGE_PTR ; pointer to the free'd page
PAGE_SIZE ; size of the freed page
DATA_PAGE ::= PAGE_HEADER
*( STREAM_ROW )
UNIX_MILLIS ::= ; unix millisecond timestamp
STREAM_ID ::= ; unique stream id
STREAM_KEY ::= ; unique stream key
*/
namespace fnordmetric {
class IDSequence;
class AOCollection : public Collection {
public:
static const uint16_t CollectionTypeId = 0x01;
static uint64_t kInitialIndexPageSize;
/**
* Constructor for a new collection
*/
AOCollection(
const Schema& schema,
std::shared_ptr page_manager,
std::unique_ptr seq);
/**
* Constructor for an exisiting collection
*/
AOCollection(
const Schema& schema,
PageManager::Page root_page,
std::shared_ptr page_manager);
AOCollection(const AOCollection& copy) = delete;
AOCollection& operator=(const AOCollection& copy) = delete;
~AOCollection() override;
/**
* Get a snapshot of this collection
*/
std::unique_ptr getSnapshot() override;
/**
* Commit a transaction on this collection. Do not call this directly unless
* you know what you are doing. Use Transaction#commit instead
*/
bool commitTransaction(const Transaction* transaction) override;
/**
* Sync the log to disk. Makes all changes until this point durable and blocks
* on what is essentialy an fsync()
*/
void sync() override;
protected:
struct __attribute__((__packed__)) DocHeader {
uint32_t checksum;
uint32_t size;
uint64_t key;
uint8_t data[];
uint32_t computeChecksum();
};
/**
* Refer to the interface documentation in "collection.h"
*/
class Snapshot : public fnordmetric::Collection::Snapshot {
public:
std::unique_ptr getCursor(const DocumentKey& key) override;
};
/**
* Refer to the interface documentation in "cursor.h"
*/
class Cursor : public fnordmetric::Cursor {
public:
size_t advanceBy(size_t n) override;
};
void appendDocument(const DocumentRef* docref,PageIndex* index);
std::shared_ptr getPageIndex() const;
uint64_t last_key_;
std::shared_ptr page_index_;
mutable std::mutex page_index_mutex_;
std::mutex commit_mutex_;
std::mutex sync_mutex_;
std::unique_ptr seq_;
};
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/btree.cc 0000664 0000000 0000000 00000002064 12556443544 0025076 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordStream" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* Licensed under the MIT license (see LICENSE).
*/
#include
#include
#include
#include
#include
#include "btree.h"
namespace fnordmetric {
BTree::BTree(uint16_t branch_factor) :
branch_factor_(branch_factor),
root_is_leaf_(true) {
root_ = allocNode(getLeafNodeSize());
}
void BTree::insert(uint64_t key) {
if (root_is_leaf_) {
if (root_->used < branch_factor_) {
return insertIntoNode(root_, key);
} else {
/* split root node */
assert(0);
}
}
}
BTree::LeafNodeEntry* BTree::lookup(uint64_t key) const {
if (root_is_leaf_) {
return (LeafNodeEntry*) root_->leaf;
}
}
BTree::Node* BTree::allocNode(size_t size) {
Node* node = (Node *) malloc(size); // FIXPAUL
memset(node, 0, size);
return node;
}
void BTree::insertIntoNode(Node* leaf_node, uint64_t key) {
auto slot = leaf_node->leaf + leaf_node->used;
slot->key = key;
leaf_node->used++;
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/btree.h 0000664 0000000 0000000 00000003065 12556443544 0024742 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_BTREE_H
#define _FNORDMETRIC_BTREE_H
#include
namespace fnordmetric {
/**
* All methods on a collection instance are threadsafe.
*/
class BTree {
friend class BTreeTest;
public:
static const uint16_t kBranchFactor = 128;
BTree(uint16_t branch_factor);
void insert(uint64_t key);
protected:
struct __attribute__((__packed__)) LeafNodeEntry {
uint64_t key;
uint64_t offset;
uint32_t size;
};
struct __attribute__((__packed__)) InternalNodeEntry {
uint64_t key;
uint64_t offset;
uint8_t is_leaf;
};
struct __attribute__((__packed__)) Node {
uint16_t used;
union __attribute__((__packed__)) {
LeafNodeEntry leaf[];
InternalNodeEntry internal[];
};
};
inline size_t getLeafNodeSize() {
return sizeof(Node) + sizeof(LeafNodeEntry) * branch_factor_;
}
inline size_t getInternalNodeSize() {
return sizeof(Node) + sizeof(InternalNodeEntry) * branch_factor_;
}
LeafNodeEntry* lookup(uint64_t key) const;
Node* allocNode(size_t size);
void insertIntoNode(Node* leaf_node, uint64_t key);
const uint16_t branch_factor_;
bool root_is_leaf_;
Node* root_;
};
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/btree_test.cc 0000664 0000000 0000000 00000002211 12556443544 0026127 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordStream" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* Licensed under the MIT license (see LICENSE).
*/
#include
#include
#include
#include
#include "btree.h"
namespace fnordmetric {
class BTreeTest {
public:
BTreeTest() {}
void run() {
testInsertIntoRoot();
testRootPageSplit();
}
void testInsertIntoRoot() {
uint16_t b = 128;
BTree btree(b);
auto root_node = btree.root_;
assert(root_node != nullptr);
for (int i=0; i < b-1; ++i) {
btree.insert(i);
}
assert(btree.root_->used == b - 1);
for (int i=0; i < b-1; ++i) {
assert(btree.root_->leaf[i].key == i);
}
assert(btree.root_ == root_node);
};
void testRootPageSplit() {
uint16_t b = 128;
BTree btree(b);
auto root_node = btree.root_;
assert(root_node != nullptr);
for (int i=0; i < (b-1) * 2; ++i) {
btree.insert(i);
}
assert(btree.root_ != root_node);
assert(btree.root_->used == 2);
};
};
}
int main() {
fnordmetric::BTreeTest test;
test.run();
printf("all tests passed! :)\n");
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/collection.cc 0000664 0000000 0000000 00000011212 12556443544 0026123 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include
#include
#include
#include
#include "collection.h"
#include "pagemanager.h"
#include "transaction.h"
#include "snapshot.h"
namespace fnordmetric {
Collection::Collection(
std::shared_ptr page_manager,
std::unique_ptr seq) :
page_manager_(std::move(page_manager)) {}
Collection::~Collection() {}
std::unique_ptr Collection::startTransaction() {
std::unique_ptr snapshot(new Snapshot());
auto transaction = new Transaction(std::move(snapshot));
return std::unique_ptr(transaction);
}
void Collection::writeRootPage(const PageManager::Page& root_page) {
PageManager::Page header_page;
header_page.offset = 0;
header_page.size = kMinReservedHeaderSize;
auto header_mmap = page_manager_->getPage(header_page);
auto file_header = header_mmap->structAt(0);
file_header->root_page_offset = root_page.offset;
file_header->root_page_size = root_page.size;
// FIXPAUL msync header
}
std::shared_ptr Collection::getPageManager() const {
return page_manager_;
}
std::unique_ptr Collection::createPersistentCollection(
const std::string& filename,
uint64_t flags /* = MODE_CONSERVATIVE */) {
Collection* ptr = nullptr;
auto open_flags = O_CREAT | O_RDWR;
if (flags & FILE_TRUNCATE) {
flags |= O_TRUNC;
} else {
flags |= O_EXCL;
}
int fd = open(filename.c_str(), open_flags, S_IRUSR | S_IWUSR);
if (fd < 0) {
perror("create file with open() failed");
return std::unique_ptr(nullptr);
}
struct stat fd_stat;
if (fstat(fd, &fd_stat) < 0) {
perror("fstat() failed");
return std::unique_ptr(nullptr);
}
/*
off_t fd_len = lseek(fd, 0, SEEK_END);
if (fd_len < 0) {
perror("lseek() failed");
return std::unique_ptr(nullptr);
}
*/
if ((flags & FILE_AUTODELETE) > 0) {
unlink(filename.c_str());
}
std::shared_ptr page_manager(
new MmapPageManager(fd, 0, fd_stat.st_blksize));
auto header_page = page_manager->allocPage(kMinReservedHeaderSize);
auto header_mmap = page_manager->getPage(header_page);
auto file_header = header_mmap->structAt(0);
file_header->magic = kFileMagicBytes;
file_header->version = kFileVersion;
//file_header->collection_type = T::CollectionTypeId;
file_header->root_page_offset = 0;
file_header->root_page_size = 0;
// FIXPAUL msync header
std::unique_ptr seq(new UnixMillisecondIDSequence());
return std::unique_ptr(new Collection(page_manager, std::move(seq)));
/* open existing file */
/*if (fd_len >= kMinReservedHeaderSize) {
PageManager::Page header_page = {.offset=0, .size=kMinReservedHeaderSize};
auto header_mmap = page_manager->getPage(header_page);
auto file_header = header_mmap->structAt(0);
if (file_header->magic != kFileMagicBytes) {
fprintf(stderr, "invalid file\n"); // FIXPAUL
return std::unique_ptr(nullptr);
}
if (file_header->version != kFileVersion) {
fprintf(stderr, "invalid file version\n"); // FIXPAUL
return std::unique_ptr(nullptr);
}
PageManager::Page first_log_page;
first_log_page.offset = file_header->first_log_page_offset;
first_log_page.size = file_header->first_log_page_size;
LogSnapshot log_snapshot;
LogReader log_reader(page_manager, first_log_page, &log_snapshot);
log_reader.import();
std::shared_ptr page_manager_imported(new MmapPageManager(
dup(fd),
fd_len,
fd_stat.st_blksize,
log_snapshot));
std::shared_ptr log(
new Log(log_snapshot, page_manager_imported));
return std::unique_ptr(
new Database(log_snapshot, log, page_manager_imported, flags));
}
fprintf(stderr, "invalid file\n"); // FIXPAUL
return std::unique_ptr(nullptr);
*/
}
bool Collection::commitTransaction(const Transaction* transaction) {
}
void Collection::sync() {
//sync_mutex_.lock();
// capture free page list
//auto index = getPageIndex();
//page_manager_->fsync();
//writeRootPage(index_page);
// release freed pages
//sync_mutex_.unlock();
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/collection.h 0000664 0000000 0000000 00000006436 12556443544 0026001 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_COLLECTION_H
#define _FNORDMETRIC_COLLECTION_H
#include
#include
#include "pagemanager.h"
#include "idsequence.h"
namespace fnordmetric {
class Transaction;
class Cursor;
class DocumentKey;
/**
* All methods on a collection instance are threadsafe.
*/
class Collection {
public:
struct __attribute__((__packed__)) FileHeader {
uint64_t magic;
uint64_t version;
uint64_t root_page_offset;
uint64_t root_page_size;
uint16_t collection_type;
};
enum kCollectionFlags {
/**
* Truncate the file when opening it
*/
FILE_TRUNCATE = 32,
/**
* Delete the file when the database is closed (the database object is
* destroyed)
*/
FILE_AUTODELETE = 64
};
/**
* File magic bytes
*/
static const uint64_t kFileMagicBytes = 0x1717171717171717;
/**
* File format version number
*/
static const uint64_t kFileVersion = 1;
/**
* Min. number of bytes to reserve for the file header
*/
static const uint64_t kMinReservedHeaderSize = 512;
/**
* Preferred maximum page size (soft limit). Default: 4MB
*/
static size_t kMaxPageSizeSoft;
/**
* Maximum allowed page size (hard limit). Note that now single row may be
* larger than the maximum page size. Default: 32MB
*/
static size_t kMaxPageSizeHard;
/**
* Create a file backed collection
*/
static std::unique_ptr createPersistentCollection(
const std::string& filename,
uint64_t flags);
/**
* Open a file backed collection
*/
static std::unique_ptr openPersistentCollection(
const std::string& filename,
uint64_t flags);
Collection(const Collection& copy) = delete;
Collection& operator=(const Collection& copy) = delete;
virtual ~Collection();
/**
* Start a new transaction on this collection
*/
std::unique_ptr startTransaction();
/**
* Sync the log to disk. Makes all changes until this point durable and blocks
* on what is essentialy an fsync()
*/
virtual void sync();
/**
* Get the internal page manager for this collection. Do not call unless you
* know what you are doing
*/
std::shared_ptr getPageManager() const;
/**
* Commit a transaction on this collection. Do not call this directly unless
* you know what you are doing. Use Transaction#commit instead
*/
virtual bool commitTransaction(const Transaction* transaction);
protected:
/**
* Constructor for a new collection
*/
explicit Collection(
std::shared_ptr page_manager,
std::unique_ptr id_sequence);
/**
* Constructor for an exisiting collection
*/
explicit Collection(
PageManager::Page root_page,
std::shared_ptr page_manager);
void writeRootPage(const PageManager::Page& root_page);
const std::shared_ptr page_manager_;
};
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/cowblob.cc 0000664 0000000 0000000 00000001017 12556443544 0025421 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include "cowblob.h"
namespace fnordmetric {
namespace ffs {
COWBlob::COWBlob(std::shared_ptr page_manager) {
}
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/cowblob.h 0000664 0000000 0000000 00000001244 12556443544 0025265 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_FFS_COWBLOB_H
#define _FNORDMETRIC_FFS_COWBLOB_H
#include "object.h"
#include
namespace fnordmetric {
namespace ffs {
class COWBlob : public Object {
public:
COWBlob(std::shared_ptr page_manager);
};
}
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/cursor.cc 0000664 0000000 0000000 00000014177 12556443544 0025322 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#include
#include
#include "cursor.h"
#include "streamref.h"
#include "database.h"
namespace fnordmetric {
namespace database {
Cursor::Cursor(
StreamRef* stream_ref,
std::shared_ptr page_manager) :
stream_ref_(stream_ref),
page_manager_(page_manager),
current_page_index_(0),
current_page_offset_(0),
current_page_(nullptr),
current_page_ref_(nullptr) {}
StreamPosition Cursor::seekToTime(uint64_t unix_millis) {
/* try to seek to the page containing that timestamp */
stream_ref_->accessPages([this, &unix_millis]
(const std::vector>& stream_pages) {
// FIXPAUL do a binary search!
for (int i = stream_pages.size() - 1; i >= 0; i--) {
if (stream_pages[i]->time_ <= unix_millis) {
this->current_page_ = stream_pages.at(i);
this->current_page_offset_ = 0;
this->current_page_index_ = 0;
break;
}
}
});
if (current_page_.get() == nullptr) {
StreamPosition pos;
pos.unix_millis = 0;
pos.logical_offset = 0;
pos.next_offset = 0;
return pos;
}
current_page_ref_ = page_manager_->getPage(current_page_->page_);
/* seek to target time */
while (next()) {
if (getCurrentRow()->time >= unix_millis) {
break;
}
}
return getCurrentPosition();
}
StreamPosition Cursor::seekToLogicalOffset(uint64_t logical_offset) {
/* try to seek to the page containing that logical_offset */
stream_ref_->accessPages([this, &logical_offset]
(const std::vector>& stream_pages) {
// FIXPAUL do a binary search!
for (int i = stream_pages.size() - 1; i >= 0; i--) {
if (stream_pages[i]->logical_offset_ <= logical_offset) {
this->current_page_ = stream_pages.at(i);
this->current_page_offset_ = 0;
this->current_page_index_ = 0;
break;
}
}
});
if (current_page_.get() == nullptr) {
StreamPosition pos;
pos.unix_millis = 0;
pos.logical_offset = 0;
pos.next_offset = 0;
return pos;
}
current_page_ref_ = page_manager_->getPage(current_page_->page_);
/* fast path for exact offset match */
current_page_offset_ = logical_offset - current_page_->logical_offset_;
if (current_page_offset_ < current_page_->used_.load()) {
auto row = current_page_ref_->structAt(current_page_offset_);
auto row_end = current_page_offset_ + row->size + sizeof(RowHeader);
if (row_end <= current_page_->used_.load()) {
if (row->computeChecksum() == row->checksum) {
return getCurrentPosition();
}
}
}
/* seek to target offset fallback */
current_page_offset_ = 0;
while (next()) {
auto cur_loff = current_page_->logical_offset_ + current_page_offset_;
if (cur_loff >= logical_offset) {
break;
}
}
return getCurrentPosition();
}
StreamPosition Cursor::seekToFirst() {
/* try to seek to the first page */
stream_ref_->accessPages([this]
(const std::vector>& stream_pages) {
if (stream_pages.size() > 0) {
this->current_page_ = stream_pages.at(0);
this->current_page_offset_ = 0;
this->current_page_index_ = 0;
}
});
if (current_page_.get() == nullptr) {
StreamPosition pos;
pos.unix_millis = 0;
pos.logical_offset = 0;
pos.next_offset = 0;
return pos;
} else {
current_page_ref_ = page_manager_->getPage(current_page_->page_);
return getCurrentPosition();
}
}
StreamPosition Cursor::seekToLast() {
/* try to seek to the last page */
stream_ref_->accessPages([this]
(const std::vector>& stream_pages) {
if (stream_pages.size() > 0) {
this->current_page_ = stream_pages.back();
this->current_page_offset_ = 0;
this->current_page_index_ = 0;
}
});
if (current_page_.get() == nullptr) {
StreamPosition pos;
pos.unix_millis = 0;
pos.logical_offset = 0;
pos.next_offset = 0;
return pos;
} else {
/* seek to the last row in the page */
current_page_ref_ = page_manager_->getPage(current_page_->page_);
while(next()) {}
return getCurrentPosition();
}
}
bool Cursor::next() {
if (current_page_.get() == nullptr) {
return false;
}
/* try to advance the offset in the current page */
auto new_offset =
current_page_offset_ + getCurrentRow()->size + sizeof(RowHeader);
if (new_offset < current_page_->used_.load()) {
current_page_offset_ = new_offset;
// FIXPAUL mem barrier if tail page / still mutable
return true;
}
auto old_page_index = current_page_index_;
/* try to advance to the next page */
stream_ref_->accessPages([this]
(const std::vector>& stream_pages) {
if (this->current_page_index_ + 1 < stream_pages.size()) {
this->current_page_index_++;
this->current_page_ = stream_pages.at(current_page_index_);
this->current_page_offset_ = 0;
}
});
if (current_page_index_ == old_page_index) {
return false;
} else {
current_page_ref_ = page_manager_->getPage(current_page_->page_);
return true;
}
}
const RowHeader* Cursor::getCurrentRow() const {
if (current_page_.get() == nullptr) {
return nullptr;
}
return current_page_ref_->structAt(current_page_offset_);
}
StreamPosition Cursor::getCurrentPosition() const {
StreamPosition pos;
if (current_page_.get() == nullptr) {
pos.unix_millis = 0;
pos.logical_offset = 0;
pos.next_offset = 0;
} else {
auto row = current_page_ref_->structAt(current_page_offset_);
pos.unix_millis = row->time;
pos.logical_offset = current_page_->logical_offset_ + current_page_offset_;
pos.next_offset = pos.logical_offset + row->size + sizeof(RowHeader);
}
return pos;
}
}
}
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/cursor.h 0000664 0000000 0000000 00000002324 12556443544 0025153 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_CURSOR_H
#define _FNORDMETRIC_CURSOR_H
#include
#include
#include
#include
#include "pagemanager.h"
namespace fnordmetric {
/**
* A storage cursor is a stateful iterator for a single dollection.
*
*/
class Cursor {
public:
Cursor(const Cursor& copy) = delete;
Cursor& operator=(const Cursor& copy) = delete;
virtual ~Cursor();
/**
* Try to advance the cursor by n documents. Returns the number of documents
* the cursor was advanced by
*/
virtual size_t advanceBy(size_t n) = 0;
protected:
//StreamRef* stream_ref_;
//std::shared_ptr current_page_;
//std::unique_ptr current_page_ref_;
//uint64_t current_page_offset_;
//size_t current_page_index_;
//std::shared_ptr page_manager_;
};
}
#endif
fnordmetric-0.1.0.20150502+gite736fba3/fnordmetric-core/src/ffs/database.h 0000664 0000000 0000000 00000014007 12556443544 0025403 0 ustar 00root root 0000000 0000000 /**
* This file is part of the "FnordMetric" project
* Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
*
* FnordMetric is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License v3.0. You should have received a
* copy of the GNU General Public License along with this program. If not, see
* .
*/
#ifndef _FNORDMETRIC_FILEBACKEND_FILEBACKEND_H
#define _FNORDMETRIC_FILEBACKEND_FILEBACKEND_H
#include
#include