master: Remove unnecessary braces in unittest

Remove unnecessary braces in goal_config_loader_unittest.
They were causing GCC 4.6 to fail.

Change-Id: Ieef9e73304a034272200d9e98171f6736c7b4c58
master: Add reading a configuration of custom goals

This commit adds reading the configuration of custom goals in the master
server and a very basic support for custom goals (all labels are treated
as wildcards).

Change-Id: I3cd82e94ec42021c3b527b734fa7bc7fae9b6a2f
master: Refactor matocsserv_getservers_wrandom

This commit changes the algorithm to make use of C++. The name of it is also
changed to matocsserv_getservers_for_new_chunk.

Change-Id: I5ed0cf66a4438c0b1a116b5e9bff4ecd9d578e67
common: Fix debug log not to generate any compiler warnings

When debug log is disabled the following code:

  DEBUG_LOG("something")

was expanded by the preprocessor to

  if (false) *static_cast<std::ofstream*>(nullptr);

Compiling such a code was generating a compiler warning about statement
which has no effect. This commit modifies the macro definition to avoid
this problem by changing it to:

  if (false) *static_cast<std::ofstream*>(nullptr) << 0;

This will also work with expressions like:

  DEBUG_LOG("something") << xxx;

which will be seen as:

  if (false) *static_cast<std::ofstream*>(nullptr) << 0 << xxx;

Change-Id: I8ce935b4b025bc53dd1e2794b7cd30217b739e09
common, master: Refactor Goal to simplify label counting

Change-Id: I8896d201daf5b60d3905a36b9b39c20fd574975d
master, tools: Add support for named goals

Add a possibility to set and get named goals using mfssetgoal/mfsgetgoal.

This commit also modifies test_moosefs_upgrade to use mfstools from
MooseFS before the master server is upgraded from mfs-1.6.27 to the
current version (new mfstools don't work with the old master server).
It also adds checking for backward compatibility of mfssetgoal and
mfsgetgoal to this test.

Change-Id: Ieae4ffa1c61ba736af27067d041b943b69bfefa0
tests: Modify test_set_get_goal to also test custom goals

Change-Id: I75e2bdadcc46ffc42fc01f3ec6e08b508383c42c
master: Add support for goals 10..20 in exports configuration

Add a possibility to set goal limits to all valid goal values, ie. from
1 to 20. Also add a test of this feature.

Change-Id: I83ca7bed74432bb5f3d2fc575f6ec168edeee049
master: Finish refactoring of matocsserv.h

In one of the the previous commits a forward declaration of struct
matocsserventry was placed in matocsserv.h. This introduced an
inconsistency in a code -- the same objects were used in chunks.cc as
void* and matocsserv* pointers. This commit finishes refactoring of
matocsserv.h header by changing all the functions in this file to
operate on matocsserv* pointers. The header is also being reformatted.
The rest of the changes is needed in order to make the code compile
after the change in matocsserv.h (all uses of void* pointing to
matocsserv entry are replaced with matocsserventry*).

Change-Id: Idc8ba5416514298cdb7caf4189ca347d0d72ebd6
chunkserver: New register messages and communication with master

This commit introduces more object-oriented packets handling in communication
between chunkservers and master server. It also adds and uses new messages for
registering chunkservers in master server.

Change-Id: I551c96493026303341a24d6694159f6636541dc4
probe: Fix printing goal limits in list-mounts command

This commit fixes an issue introduced in one of the previous commits
which makes lizardfs-probe unable to print values of default goal limits
(which are now 1-20), because these numbers don't fulfill the condition:

  mount.maxGoal >= 1 && mount.maxGoal <= 9

The test test_probe_list_mounts also needed to be changed to reflect
the change in the default values.

Change-Id: Id3c29b83144c925c1e4cc2e3575239d0161339b7
test: Extend framework to handle custom goals easier

This commit adds a new option to setup_local_empty_lizardfs which can be
used like this:

  MASTER_CUSTOM_GOALS="8 X:  _ _ _ trash|14 bettergoal: _ _ _ trash trash"

to configure custom goals in a test's installation. This entry generates
a file with configuration of goals and adds its location to the config
file of all metadata servers.

Change-Id: I0595cc270d9b4738234b6fbbfdd65ae39ae088aa
chunkserver: Add labeling of chunkservers

This commit introduces LABEL config option for naming chunkserver to be defined
for extended goal management. It also sends a label to the master server during
registering.

Change-Id: I72b256006175ce329d10fd99fa69e9f6841b391a
master: Fix loading mfsgoals.cfg

When mfsmaster.cfg doesn't specify CUSTOM_GOALS_FILENAME, load
mfsgoals.cfg from the default location instead of using default goal
definitions.

Detect and report I/O failures during loading.

Change-Id: I939750ada4d9704d4810344422ed219d413ee46d
master: Modify algorithm of creating new chunks to respect labels

This commit changes the algorithm which chooses chunkservers to place
a new chunk. Now it makes use of custom goals and media labels.

Te algorithm is changed in a way that it no longer maintains 'carry'
between runs, which means that for each new chunk each chunkserver is
chosen completely randomly (with respect to weights equal its total disk
space though). The previous implementation was trying to distribute
chunks more evenly, but making it random shouldn't influence the
observed behavior of the system.

Change-Id: I335e6b116fa9c1678665781cf52f675533c316d0
tests: Add a test test_creating_new_chunks_with_labels

This test verifies if new chunks are created with respect to
labels of chunkservers.

Change-Id: I2f847f9b113027c7feca06b2ab95ea74ec81d8ef
tests: Add test_many_serverrooms

This commit adds a test which verifies if we can configure the system in
a way that files are readable after losing two out of three server
rooms.

Change-Id: Ib418c002f84f2b9c0374cf509f462b6b92f9619d
common: Implement std::set and std::map serialization

Change-Id: I0961688954a30d0147a02992a6e640edb4455414
common: Change GoalMap serialization

Make GoalMap use std::map instead of fixed size array when serializing.
This change will make it possible to pass GoalMaps through the network
between two modules in two diffrent version, being aware of diffrent
number of possible goals.

Change-Id: I7a23e809f7fdfc60cd6b390cfe2311470abc3e4f
common: Make vector serialization support custom allocators

Change-Id: I1ce44095fbee1cfbf6e5a3a89e8053dcdd79493f