Posts

Debug a C/C++ application which requires root privileges using Eclipse CDT

Image
Spanish version / Versión en Español Hi! It's been a long time, but this blog is not dead! It just happened that so far, I haven't ran into a case which hadn't been documented by someone else already. I am glad to inform that today, I found good enough reason to make a post, since the information was already in the web, but scattered among different sites. So I am putting it together here for future reference. Going back to the problem described in the title: initially, you would think that for a scenario like this, the only way is to run Eclipse itself with root privileges. However, security concerns aside, doing so would imply losing all the Eclipse settings, because they would be associated to the original non-root user. The optimal solution would be to refactor the application to avoid requiring root privileges. Sometimes, that can be achieved without even touching the app's source code. For example, it might be possible to define a user group with the...

Depurar una aplicación C/C++ que requiere privilegios de root usando Eclipse CDT

Image
Versión en inglés / English version ¡Hola! Ha pasado mucho tiempo, ¡pero este blog sigue con vida! El problema fue que en todo este tiempo, todos los temas con los que me topé ya estaban documentados en detalle en la web. Es un placer informar que hoy encontré una buena razón para postear, ya que la información estaba en la web, pero desperdigada entre diversos sitios. Así que la recopilé aquí para referencia futura. Volviendo al problema mencionado en el título: inicialmente, uno pensaría que para un escenario así, la única solución sería ejecutar Eclipse con privilegios administrativos, o sea como root . Sin embargo, más allá de los potenciales problemas de seguridad, hacer eso implicaría perder toda la configuración de Eclipse, porque la misma está asociada al usuario original, que no es root . La mejor solución sería refactorizas la aplicación para que no requiera privilegios administrativos. A veces, eso puede hacerse incluso sin tocar el código fuente. Por ejemplo, ...

Apache Kafka - V - Consumer Groups

Image
Spanish version / Versión en Español A single consumer, having to receive and process messages in a single thread, can soon become a bottleneck, especially as producers, topics and partitions grow in number. Kafka overcomes this limitation by allowing consumers to share their load as evenly as possible by setting the group.id option on creation, and thus belonging to a consumer group. When a bunch of consumers set the same group id, a broker inside the cluster is automatically assigned as the group coordinator: his goal will be to monitor the consumers and keep track of their membership. The group coordinator also communicates with Zookeeper and the cluster controller/leader node in order to assign partitions to each consumer in the group. The ideal situation is to have consumer and partitions evenly matched, i.e. each consumer will read only one partition from the topic. Each consumer regularly sends a heartbeat to the cluster (with a frequency defined by t...

Apache Kafka - V - Consumer Groups

Image
Versión en inglés / English version Un solo consumidor, teniendo que recibir y procesar mensajes en un solo thread , puede volverse rápidamente un cuello de botella. Este problema se acrecenta al aumentar la cantidad de topics y particiones. Kafka resuelve esta limitación permitiendo que varios consumidores repartan su carga de manera equitativa fijando el mismo valor en la propiedad group.id al momento de su creación. Haciendo esto, pasan a pertenecer al mismo consumer group . Cuando un conjunto de consumidores tiene el mismo id de grupo, un broker dentro del cluster es asignado automáticamente como el coordinador del grupo. Su objetivo será monitorear a los consumidores del grupo y llevar cuenta de su pertenencia al mismo. El coordinador del grupo también se comunica con Zookeeper para balancear consumidores y particiones: idealmente, cada consumidor leerá una partición distinta del topic . Cada consumidor envía periódicamente un heartbeat al cluster ...

Apache Kafka - IV - Consumers

Image
Spanish version / Versión en Español A basic Kafka consumer application, using the same library used for producers in part 3 , could be: public class KafkaConsumerApp{ public static void main([]String args) { Properties props = new Properties(); props.put("bootstrap.servers", "BROKER-1:9092, BROKER-2:9093"); props.put("key.deserializer", "org.apache.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.common.serialization.StringDeserializer"); KafkaConsumer myConsumer = new KafkaConsumer(props); myConsumer.subscribe(Arrays.asList("my-topic")); try{ while (true) { ConsumerRecords<String, String> records = myConsumer.poll(100); processRecords(records); } } catch (Exception ex) { ex.printStackTrace(); } finally { myCon...

Apache Kafka - IV - Consumidores

Image
Versión en inglés / English version Una aplicación consumidora básica, usando la misma biblioteca que en la parte 3 , podría ser: public class KafkaConsumerApp{ public static void main([]String args) { Properties props = new Properties(); props.put("bootstrap.servers", "BROKER-1:9092, BROKER-2:9093"); props.put("key.deserializer", "org.apache.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.common.serialization.StringDeserializer"); KafkaConsumer myConsumer = new KafkaConsumer(props); myConsumer.subscribe(Arrays.asList("my-topic")); try{ while (true) { ConsumerRecords<String, String> records = myConsumer.poll(100); processRecords(records); } } catch (Exception ex) { ex.printStackTrace(); } finally { myConsumer.c...

Apache Kafka - III - Producers

Spanish version / Versión en Español All code examples in this post will be in Java , for simplicity; however, keep in mind that Kafka offers client libraries in a myriad of languages. More specifically, in a Maven project, the Kafka dependency can be defined by: groupId: org.apache.kafka artifactId: kafka-clients version: 0.10.0.1 (or newer if available) So, to create a producer, some basic properties are required (although there are many, many more optional properties to tweak): Properties props = new Properties(); props.put("bootstrap.servers", "BROKER-1:9092, BROKER-2:9093"); props.put("key.serializer", "org.apache.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.common.serialization.StringSerializer"); The bootstrap.servers property defines a list of brokers in the cluster the producer can connect to. It doesn't need to be a full list of the cluster...