1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Improvents for storage - if broken line found in storage, it will be ignored.

This commit is contained in:
zbeacon
2019-12-11 16:46:46 +02:00
parent 4ffcf4f015
commit dada6430bb
2 changed files with 10 additions and 4 deletions

View File

@@ -208,8 +208,8 @@ class TBGatewayService:
self.__published_events.append(self.tb_client.client.gw_send_attributes(current_event["deviceName"],
filtered_attributes))
success = True
for event in range(len(self.__published_events)):
success = self.__published_events[event].get() == self.__published_events[event].TB_ERR_SUCCESS
for event in self.__published_events:
success = event.get() == event.TB_ERR_SUCCESS
if success:
self.__event_storage.event_pack_processing_done()
except Exception as e:

View File

@@ -48,6 +48,12 @@ class EventStorageReader:
records_to_read -= 1
except IOError as e:
log.warning("Could not parse line [%s] to uplink message! %s", line, e)
except Exception as e:
log.exception(e)
current_line_in_file += 1
self.new_pos.set_line(current_line_in_file)
self.write_info_to_state_file(self.new_pos)
break
finally:
current_line_in_file += 1
if records_to_read > 0:
@@ -66,6 +72,7 @@ class EventStorageReader:
self.delete_read_file(previous_file)
self.new_pos = EventStorageReaderPointer(next_file, 0)
self.write_info_to_state_file(self.new_pos)
continue
else:
# No more records to read for now
break
@@ -86,7 +93,7 @@ class EventStorageReader:
def discard_batch(self):
try:
if self.current_pos.get_line() >= self.settings.get_max_records_per_file():
if self.current_pos.get_line() >= self.settings.get_max_records_per_file()-1:
if self.buffered_reader is not None and not self.buffered_reader.closed:
self.buffered_reader.close()
self.write_info_to_state_file(self.new_pos)
@@ -107,7 +114,6 @@ class EventStorageReader:
found = True
return target_file
def get_or_init_buffered_reader(self, pointer):
try:
if self.buffered_reader is None or self.buffered_reader.closed: