Merge branch '2.0' into develop
This commit is contained in:
@ -774,48 +774,54 @@ static bool avro_client_stream_data(AVRO_CLIENT *client)
|
||||
char filename[PATH_MAX + 1];
|
||||
snprintf(filename, PATH_MAX, "%s/%s", router->avrodir, client->avro_binfile);
|
||||
|
||||
bool ok = true;
|
||||
|
||||
spinlock_acquire(&client->file_lock);
|
||||
if (client->file_handle == NULL)
|
||||
if (client->file_handle == NULL &&
|
||||
(client->file_handle = maxavro_file_open(filename)) == NULL)
|
||||
{
|
||||
client->file_handle = maxavro_file_open(filename);
|
||||
ok = false;
|
||||
}
|
||||
spinlock_release(&client->file_lock);
|
||||
|
||||
switch (client->format)
|
||||
if (ok)
|
||||
{
|
||||
case AVRO_FORMAT_JSON:
|
||||
/** Currently only JSON format supports seeking to a GTID */
|
||||
if (client->requested_gtid &&
|
||||
seek_to_index_pos(client, client->file_handle) &&
|
||||
seek_to_gtid(client, client->file_handle))
|
||||
switch (client->format)
|
||||
{
|
||||
client->requested_gtid = false;
|
||||
case AVRO_FORMAT_JSON:
|
||||
/** Currently only JSON format supports seeking to a GTID */
|
||||
if (client->requested_gtid &&
|
||||
seek_to_index_pos(client, client->file_handle) &&
|
||||
seek_to_gtid(client, client->file_handle))
|
||||
{
|
||||
client->requested_gtid = false;
|
||||
}
|
||||
|
||||
read_more = stream_json(client);
|
||||
break;
|
||||
|
||||
case AVRO_FORMAT_AVRO:
|
||||
read_more = stream_binary(client);
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_ERROR("Unexpected format: %d", client->format);
|
||||
break;
|
||||
}
|
||||
|
||||
read_more = stream_json(client);
|
||||
break;
|
||||
|
||||
case AVRO_FORMAT_AVRO:
|
||||
read_more = stream_binary(client);
|
||||
break;
|
||||
if (maxavro_get_error(client->file_handle) != MAXAVRO_ERR_NONE)
|
||||
{
|
||||
MXS_ERROR("Reading Avro file failed with error '%s'.",
|
||||
maxavro_get_error_string(client->file_handle));
|
||||
}
|
||||
|
||||
default:
|
||||
MXS_ERROR("Unexpected format: %d", client->format);
|
||||
break;
|
||||
/* update client struct */
|
||||
memcpy(&client->avro_file, client->file_handle, sizeof(client->avro_file));
|
||||
|
||||
/* may be just use client->avro_file->records_read and remove this var */
|
||||
client->last_sent_pos = client->avro_file.records_read;
|
||||
}
|
||||
|
||||
|
||||
if (maxavro_get_error(client->file_handle) != MAXAVRO_ERR_NONE)
|
||||
{
|
||||
MXS_ERROR("Reading Avro file failed with error '%s'.",
|
||||
maxavro_get_error_string(client->file_handle));
|
||||
}
|
||||
|
||||
/* update client struct */
|
||||
memcpy(&client->avro_file, client->file_handle, sizeof(client->avro_file));
|
||||
|
||||
/* may be just use client->avro_file->records_read and remove this var */
|
||||
client->last_sent_pos = client->avro_file.records_read;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -73,6 +73,7 @@ int index_query_cb(void *data, int rows, char** values, char** names)
|
||||
void avro_index_file(AVRO_INSTANCE *router, const char* filename)
|
||||
{
|
||||
MAXAVRO_FILE *file = maxavro_file_open(filename);
|
||||
|
||||
if (file)
|
||||
{
|
||||
char *name = strrchr(filename, '/');
|
||||
@ -166,6 +167,10 @@ void avro_index_file(AVRO_INSTANCE *router, const char* filename)
|
||||
|
||||
maxavro_file_close(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Failed to open file '%s' when generating file index.", filename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
if(BUILD_TESTS)
|
||||
add_executable(testbinlogrouter testbinlog.c ../blr.c ../blr_slave.c ../blr_master.c ../blr_file.c ../blr_cache.c)
|
||||
target_link_libraries(testbinlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
||||
add_test(TestBinlogRouter ${CMAKE_CURRENT_BINARY_DIR}/testbinlogrouter)
|
||||
add_test(NAME TestBinlogRouter COMMAND ./testbinlogrouter WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user